Slider

Alignment target:@astryxdesign/core v0.7.1 · Slider

Volume

Usage #

Use Slider to choose a number or numeric range.

Vue
<script setup lang="ts">
import { Slider } from '@astryx-vue/core/Slider'
import { shallowRef } from 'vue'

const volume = shallowRef(50)
const budget = shallowRef<[number, number]>([20, 80])
</script>

<template>
  <Slider v-model="volume" label="Volume" />
  <Slider v-model="budget" label="Budget" value-display="text" />
</template>

Import the theme once in the application entry:

TypeScript
import '@astryx-vue/themes/neutral.css'

Anatomy

ElementDescription
LabelText identifying the numeric setting controlled by the slider.
DescriptionHelper text between the label and the slider control.
SliderControl row containing the track, thumb or thumbs, and optional text value.
Interactive controlPointer and keyboard interaction surface containing the rail, fill, marks, and thumbs.
TrackBackground rail representing the available numeric range.
Filled rangeAccent segment from the minimum to a single value, or between two range values.
Tick markPosition marker supplied through the marks collection.
Mark labelOptional text displayed beside a tick mark.
ThumbDraggable value indicator; range mode renders a minimum and maximum thumb.
Value displayFormatted current value shown beside the slider when valueDisplay is text.
Value tooltipFormatted current value shown in a tooltip when valueDisplay is tooltip.
Status messageError, warning, or success message below the slider.

Best practices #

GuidancePractices
DoAlways provide a label, even if visually hidden, so the slider is accessible to screen readers.
DoFormat values with meaningful units like "$50" or "75%" instead of raw numbers.
Don'tUse for precise numeric entry; pair with a text input or use NumberInput instead.
Don'tSet a step size so large that only a few positions are possible; use SegmentedControl or radio buttons instead.
Don'tWrap a disabled slider in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.

Examples #

Slider — Formatted value

Temperature
Open in Playground

Temperature in Fahrenheit, shown beside the slider.

Slider — Range

Price range
Minimum valueMaximum value
Open in Playground

A price range with a lower and an upper thumb.

Slider — Marks

Volume
Open in Playground

Volume with tick labels at 0, 25, 50, 75, and 100.

Slider — Validation states

CPU Usage
CPU usage is critically high
Memory
Memory usage is moderate
Disk
Disk usage is healthy
Open in Playground

Error, warning, and success on CPU, memory, and disk.

Keyboard controls #

The slider is fully operable with the keyboard, so users never have to drag. Once a thumb has focus, these keys change its value:

  • Tab moves focus to each thumb in turn.
  • Left / Right move one step in the horizontal direction; the direction is reversed in right-to-left layouts.
  • Up / Down increase or decrease the value by one step.
  • PageUp / PageDown increase or decrease the value by ten steps.
  • Home / End move to the allowed minimum or maximum.
  • Escape closes the value tooltip or the disabled reason tooltip.

In range mode each thumb has its own name, taken from minLabel and maxLabel, so assistive technology can tell which bound is being adjusted. Each thumb's ARIA bounds also update when its sibling changes, so the range that is announced always matches the values the thumb can actually take.

Usage guidance #

A slider suits choosing a value along a continuous range, not entering an exact number. Keep the following in mind:

  • Provide a numeric input when exact entry matters.
  • isRequired only provides a required description, so assistive technology knows the field is required.
  • Validate accepted values in application code.