WlSlider
Limits
Volume: 40%
Value: 50
Range: 20 – 80
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlSlider } from "legato-ui";
import { computed, ref } from "vue";
const volume = ref(40);
const marked = ref(50);
const range = ref<[number, number]>([20, 80]);
const marks = [0, 25, 50, 75, 100];
const rangeMode = computed(() => props.preview?.range === true);
</script>
<template>
<div class="wl-stack" data-space="md">
<template v-if="rangeMode">
<WlSlider
v-model="range"
:min="0"
:max="100"
:step="10"
range
aria-label="Range with marks"
/>
<p class="wl-text-small">{{ "Range:" }} {{ range.join(' – ') }}</p>
</template>
<template v-else>
<WlSlider
v-model="volume"
:min="0"
:max="100"
:step="10"
:range="false"
aria-label="Volume"
/>
<p class="wl-text-small">{{ "Volume:" }} {{ volume }}%</p>
</template>
<WlSlider
v-model="marked"
:range="false"
:marks="marks"
aria-label="Slider with marks"
/>
<p class="wl-text-small">{{ "Value:" }} {{ marked }}</p>
<template v-if="!rangeMode">
<WlSlider
v-model="range"
range
:marks="marks"
aria-label="Range with marks"
/>
<p class="wl-text-small">{{ "Range:" }} {{ range.join(' – ') }}</p>
</template>
</div>
</template>Selection
Volume: 40%
Value: 50
Range: 20 – 80
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlSlider } from "legato-ui";
import { computed, ref } from "vue";
const volume = ref(40);
const marked = ref(50);
const range = ref<[number, number]>([20, 80]);
const marks = [0, 25, 50, 75, 100];
const rangeMode = computed(() => props.preview?.range === true);
</script>
<template>
<div class="wl-stack" data-space="md">
<template v-if="rangeMode">
<WlSlider
v-model="range"
:min="0"
:max="100"
:step="10"
range
aria-label="Range with marks"
/>
<p class="wl-text-small">{{ "Range:" }} {{ range.join(' – ') }}</p>
</template>
<template v-else>
<WlSlider
v-model="volume"
:min="0"
:max="100"
:step="10"
:range="false"
aria-label="Volume"
/>
<p class="wl-text-small">{{ "Volume:" }} {{ volume }}%</p>
</template>
<WlSlider
v-model="marked"
:range="false"
:marks="marks"
aria-label="Slider with marks"
/>
<p class="wl-text-small">{{ "Value:" }} {{ marked }}</p>
<template v-if="!rangeMode">
<WlSlider
v-model="range"
range
:marks="marks"
aria-label="Range with marks"
/>
<p class="wl-text-small">{{ "Range:" }} {{ range.join(' – ') }}</p>
</template>
</div>
</template>Ranges and current value
Two constrained ranges with different steps, text outputs, disabling and reset.
Range, step and current value
Arrow keys, Home and End control the native range. The current value appears as a number beside it.
Unavailable slider
Volume: 40%. Interval: 20 minutes.
Full example
<script setup lang="ts">
import { WlButton, WlField, WlSlider } from "legato-ui";
import { ref } from "vue";
const volume = ref(40);
const interval = ref(20);
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlSlider">
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Range, step and current value" }}</h3>
<WlField
id="docs-slider-volume"
v-slot="{ id, ariaDescribedby }"
label="Volume"
hint="From 0 to 100, step 5."
>
<WlSlider
:id="id"
v-model="volume"
:min="0"
:max="100"
:step="5"
aria-label="Volume"
:aria-describedby="ariaDescribedby"
/>
<output :for="id" class="wl-text-small" aria-label="Volume">{{ volume }}%</output>
</WlField>
<WlField
id="docs-slider-interval"
v-slot="{ id, ariaDescribedby }"
label="Interval, minutes"
hint="From 10 to 50, step 10."
>
<WlSlider
:id="id"
v-model="interval"
:min="10"
:max="50"
:step="10"
aria-label="Interval"
:aria-describedby="ariaDescribedby"
/>
<output :for="id" class="wl-text-small" aria-label="Interval">{{
interval
}} {{ "minutes" }}</output>
</WlField>
<p class="wl-text-small wl-text-muted">{{ "Arrow keys, Home and End control the native range. The current value appears as a number beside it." }}</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Unavailable slider" }}</h3>
<WlField id="docs-slider-disabled" v-slot="{ id }" label="Fixed level"><WlSlider
:id="id"
:model-value="60"
disabled
aria-label="Fixed level"
/><output :for="id" class="wl-text-small" aria-label="Fixed level">60%</output></WlField>
<WlButton size="sm" @click="volume = 40; interval = 20">{{ "Reset ranges" }}</WlButton>
<p class="wl-text-small" role="status">{{
"Volume:"
}} {{
volume
}}{{
"%. Interval:"
}} {{
interval
}} {{
"minutes."
}}</p>
</section>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: number |Value (default 0).
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
min | number | 0 | Minimum. |
max | number | 100 | Maximum. |
step | number | 1 | Step. |
disabled | boolean | false | Disables the slider. |
ariaLabel | string | Not set | aria-label. |
invalid | boolean | false | Expose a validation error state on the control. |
range | boolean | false | Use two slider handles with a start/end value pair. |
size | WlSizeSm | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
ariaValueText | string | | Not set | Human-readable value text for assistive technology. |
startLabel | string | Not set | Accessible label for the range start control. |
endLabel | string | Not set | Accessible label for the range end control. |
marks | readonly (number | | [] | Labeled positions displayed along the slider track. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | number | | Emitted when the component requests a model change; the payload is the next value. |
Slots
No public slots.
Pass-through: pt
Sections WlSlider are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | input.wl-slider | Main element of the component. |
input | input | Native input that receives focus and control attributes. |
marks | div.wl-slider__marks | Container for slider marks. |
mark | span.wl-slider__mark | One labelled slider mark. |
label | span | Visible component label. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Give the native range input ariaLabel and a visible label. Show the current numeric value next to the slider; thumb position and track colour support it.
- Arrows change the value by step; Home/End select range endpoints. The native element enforces min/max.
- The model is a number. Associate units and range guidance with the field through aria-describedby.
- disabled disables controls. The public contract has no invalid, size or density; show consumer validation in separate text.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.