Slider
Slider is an unstyled slider for one value or multiple thumbs. It renders a track, filled range, and role="slider" thumbs with pointer dragging, keyboard stepping, hidden form input support, and CSS variables for styling.
Use it when users can choose an approximate value by dragging. Use Number Field when exact typed input matters.
Anatomy
#range: Custom content inside the filled range.#thumb: Custom content inside each focusablerole="slider"thumb.
The root, hidden inputs, track, range, and thumbs are generated by the component. The root sets --akaza-slider-percentage, --akaza-slider-start-percentage, and --akaza-slider-end-percentage for styling.
Usage
Value: 60
Examples
Range slider
Bind v-model to a number array. Provide aria-labels so each thumb has a clear accessible name.
<script setup lang="ts">
import { ref } from "vue";
import { Slider } from "akaza-ui";
const price = ref([20, 80]);
</script>
<template>
<Slider
v-model="price"
:min="0"
:max="100"
:step="5"
:aria-labels="['Minimum price', 'Maximum price']"
/>
</template>
Minimum distance between thumbs
minStepsBetweenThumbs keeps adjacent thumbs apart by step units.
<template>
<Slider v-model="range" :step="5" :min-steps-between-thumbs="2" />
</template>
Vertical slider
Use orientation="vertical" and give the root/track a visible height.
<template>
<Slider
v-model="volume"
orientation="vertical"
aria-label="Volume"
:ui="{ root: 'h-40 w-6', track: 'h-full w-2' }"
/>
</template>
Inverted direction
inverted reverses pointer and keyboard value direction.
<template>
<Slider v-model="brightness" inverted aria-label="Brightness" />
</template>
Custom thumb content
Use #thumb when the thumb needs visible value text or custom markup.
<template>
<Slider v-model="value" aria-label="Progress">
<template #thumb="{ value }">
<span>{{ value }}</span>
</template>
</Slider>
</template>
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | field id | Thumb id. |
name | string | field name | Form field name. Renders hidden range input. |
min | number | 0 | Minimum value. |
max | number | 100 | Maximum value. |
step | number | 1 | Keyboard and pointer snapping step. |
orientation | "horizontal" | "vertical" | "horizontal" | Slider orientation. |
minStepsBetweenThumbs | number | 0 | Minimum distance between adjacent thumbs, in step units. |
inverted | boolean | false | Reverses value direction. |
thumbAlignment | "center" | "contain" | "center" | Thumb alignment metadata exposed as a data attr. |
required | boolean | false | Required state for hidden input. |
disabled | boolean | false | Disabled state. |
invalid | boolean | false | Sets invalid attrs. |
ariaLabel | string | — | Accessible label when no visible label exists. |
ariaLabels | string[] | — | Per-thumb accessible labels for range sliders. |
ariaLabelledby | string | — | Accessible label id. |
ariaDescribedby | string | field description/error | Accessible description ids. |
getValueLabel | (value, max) => string | undefined | — | Human-readable aria-valuetext. |
ui | SliderUi | — | Classes for structural parts. |
Emits
| Event | Payload | Description |
|---|---|---|
value-change | (value: number | number[], details) | Fired before model updates. details.cancel() prevents the update. |
value-commit | (value: number | number[], details) | Fired at the end of pointer or keyboard interaction. |
Slots
| Slot | Props | Description |
|---|---|---|
range | value, values, percentage, percentages | Custom range content. |
thumb | value, values, index, percentage, percentages | Custom thumb content. |
UI Options
| Key | Description |
|---|---|
root | Root slider wrapper. |
input | Hidden range input used for form submission. |
track | Slider track. |
range | Filled range. |
thumb | Slider thumb with role="slider". |
Styling Hooks
| UI key | CSS class | Data attrs |
|---|---|---|
root | akaza-slider | data-akaza-orientation, data-akaza-disabled, data-akaza-invalid, data-akaza-dragging, data-akaza-focused, data-akaza-inverted, data-akaza-thumb-alignment |
input | akaza-slider-input | — |
track | akaza-slider-track | same slider state attrs |
range | akaza-slider-range | same slider state attrs |
thumb | akaza-slider-thumb | same slider state attrs, data-akaza-thumb-index, and ARIA slider attrs |
Slider sets --akaza-slider-percentage, --akaza-slider-start-percentage, and --akaza-slider-end-percentage on the root. Plain class applies to the root wrapper.
Native invalid state from the hidden form input is revealed after interaction or invalid submit. Controlled invalid state from the invalid prop or parent Field appears immediately.
Keyboard
| Key | Behavior |
|---|---|
ArrowRight / ArrowUp | Increment by step. |
ArrowLeft / ArrowDown | Decrement by step. |
PageUp / PageDown | Increment/decrement by step * 10. |
Home / End | Set to min/max. |