✦ Asteria UI
Components

Slider

A range input control for selecting a numeric value within a defined range.

Installation

npx asteria-ui add slider

Usage

import { Slider } from "@/components/ui/slider";

<Slider aria-label="Volume" defaultValue={[40]} />

Examples

Sizes

States

API reference

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"Track/thumb size.
errorbooleanfalseShows the track fill and thumb in the error color.
defaultValuenumber[]Uncontrolled initial value — a single-element array for one thumb.
valuenumber[]Controlled value — pair with onValueChange.
minnumber0Minimum value.
maxnumber100Maximum value.
stepnumber1Increment per keyboard/drag step.
disabledbooleanfalsePrevents interaction.

Accessibility

Accessibility

  • Role. The thumb carries role="slider" with aria-valuenow, aria-valuemin, aria-valuemax. Always pass aria-label or aria-labelledby.

  • Keyboard. Arrow keys adjust by step. Page Up/Down move by a larger increment. Home/End jump to min/max.

  • Touch target. The thumb's hit area meets the 44×44px minimum on mobile even though its visible size is smaller.

  • Focus ring. Visible on Tab via shadow-glow-focus.

When to use

Use for selecting a value in a continuous range — volume, brightness, price range. Best when exact value matters less than relative position.

Do:

  • Show the current value
  • Define clear min/max labels
  • Use step increments for discrete values

Don't:

  • Use for precise entry — use Input instead
  • Make the track too short to use accurately
  • Combine with an input field without keeping them in sync