Forms & inputs
Layout
Slider
A track with one thumb for a value, or two for a range. Use it to pick a number by dragging.
Validating a form? vael-form wires this up with a schemaInstall
import { Slider } from 'vael-ui'Playground
horizontal
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Slider } from 'vael-ui'
const value = ref(0)
</script>
<template>
<Slider aria-label="Volume" v-model="value" />
</template>Motion New
Slider's motion: values or hooks for its parts (SliderPart), its states (disabled, focus), how its value changes. false turns it off.
<Slider
:motion="{ states: { disabled: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | roottrackfillthumb | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
states | disabledfocus | Sets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
spring | { damping, response } | Times how its value moves when it changes, from the steppers, the keyboard or your code. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Slider pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| ArrowRightArrowUp | Increases the value by one step. |
| ArrowLeftArrowDown | Decreases the value by one step. |
| PageUp | Increases the value by ten steps. |
| PageDown | Decreases the value by ten steps. |
| Home | Sets the value to min. |
| End | Sets the value to max. |
- Each thumb has
role="slider"witharia-valuenow,aria-valueminandaria-valuemax, plusaria-orientation="vertical"when vertical andaria-invalidwhen invalid.valueTextsetsaria-valuetext, such as a price with its currency. - In a range, the thumbs are named “Minimum” and “Maximum” after the label. Each thumb’s
aria-valueminoraria-valuemaxstops at the other thumb. - Inside a
Field, the label names the thumbs. Without one, passaria-label: it moves from the wrapper to the thumbs, asaria-describedbydoes. - Pressing the track moves the nearest thumb there and focuses it. Right to left, ArrowLeft and ArrowRight swap; a vertical slider keeps its keys.