Skip to content

Slider

Choose a value or range by dragging a handle or using the keyboard.

Demos

Size

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Slider.vue and index.ts into app/components/ui/slider/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

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.
ariaLabelstring—Accessible label when no visible label exists.
ariaLabelsstring[]—Per-thumb accessible labels for range sliders.
ariaLabelledbystring—Accessible label id.
ariaDescribedbystringfield description/errorAccessible description ids.
getValueLabel(value, max) => string | undefined—Human-readable aria-valuetext.
uiSliderUi—Classes for structural parts.

Slots

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

Events

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.

Keyboard

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