Components

Slider

Single-value or range slider with pointer drag, keyboard step, and ARIA metadata.

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 focusable role="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

PropTypeDefaultDescription
idstringfield idThumb id.
namestringfield nameForm field name. Renders hidden range input.
minnumber0Minimum value.
maxnumber100Maximum value.
stepnumber1Keyboard and pointer snapping step.
orientation"horizontal" | "vertical""horizontal"Slider orientation.
minStepsBetweenThumbsnumber0Minimum distance between adjacent thumbs, in step units.
invertedbooleanfalseReverses value direction.
thumbAlignment"center" | "contain""center"Thumb alignment metadata exposed as a data attr.
requiredbooleanfalseRequired state for hidden input.
disabledbooleanfalseDisabled state.
invalidbooleanfalseSets invalid attrs.
ariaLabelstringAccessible label when no visible label exists.
ariaLabelsstring[]Per-thumb accessible labels for range sliders.
ariaLabelledbystringAccessible label id.
ariaDescribedbystringfield description/errorAccessible description ids.
getValueLabel(value, max) => string | undefinedHuman-readable aria-valuetext.
uiSliderUiClasses for structural parts.

Emits

EventPayloadDescription
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

SlotPropsDescription
rangevalue, values, percentage, percentagesCustom range content.
thumbvalue, values, index, percentage, percentagesCustom thumb content.

UI Options

KeyDescription
rootRoot slider wrapper.
inputHidden range input used for form submission.
trackSlider track.
rangeFilled range.
thumbSlider thumb with role="slider".

Styling Hooks

UI keyCSS classData attrs
rootakaza-sliderdata-akaza-orientation, data-akaza-disabled, data-akaza-invalid, data-akaza-dragging, data-akaza-focused, data-akaza-inverted, data-akaza-thumb-alignment
inputakaza-slider-input
trackakaza-slider-tracksame slider state attrs
rangeakaza-slider-rangesame slider state attrs
thumbakaza-slider-thumbsame 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

KeyBehavior
ArrowRight / ArrowUpIncrement by step.
ArrowLeft / ArrowDownDecrement by step.
PageUp / PageDownIncrement/decrement by step * 10.
Home / EndSet to min/max.