Slider
Primitive

Slider

Headless slider primitives for single-value and range inputs.

Live behavior

Slider in motion

Interactive
Atom behavior · App-owned appearance
Preparing behavior…

Use arrow keys or drag the thumb to change the value.

waiting for input

When to Use

Use Slider when someone adjusts a number by feel, such as volume, zoom, or a price range. Use NumberInput when the exact typed number matters, and use Progress when the value is read-only and only reports work being completed.

Features

The behavior Atom owns before your product adds appearance.

  • Supports single-value and multi-thumb range values.
  • Supports controlled and uncontrolled values.
  • Supports horizontal and vertical orientation.
  • Supports pointer dragging, keyboard changes, and commit callbacks.
  • Preserves page scrolling on the non-slider axis, reverts true pointer cancellation, and commits the latest value when capture is lost.
  • Supports hidden form inputs.
  • Supports Direction.Provider for horizontal right-to-left pointer and keyboard behavior.
  • Exposes geometry through data attributes and inline offset styles.

Import

tsx
import { Slider } from "@flowstack-ui/atom";

Anatomy

tsx
<Slider.Root>
  <Slider.Track>
    <Slider.Range />
    <Slider.Thumb />
  </Slider.Track>
</Slider.Root>

API Reference

Root

Owns the numeric range, thumb values, pointer calculations, keyboard changes, and hidden form inputs. Root renders a div; each Thumb owns slider semantics.

PropTypeDefault
valuenumber | number[]-
defaultValuenumber | number[][min]
onValueChange(value) => void-
onValueCommit(value) => void-
minnumber0
maxnumber100
stepnumber1
largeStepnumberstep * 10
minStepsBetweenThumbsnumber0
disabledbooleanField state or false
readOnlybooleanField state or false
invalidbooleanField state or false
requiredbooleanField state or false
orientation"horizontal" | "vertical""horizontal"
dir"ltr" | "rtl"Direction context
namestring-
formstring-
aria-labelstringField label relationship
ariaValueText(value: number) => string-

ARIA: Root adds no role or ARIA attributes. Its label and value-text props are applied to each Thumb.

Data attributeValues
[data-slot]"slider"
[data-orientation]"horizontal" | "vertical"
[data-disabled]Present when disabled

Track

Registers the pointer interaction surface used to choose and drag the nearest Thumb. It renders a div by default. Horizontal Tracks preserve vertical page scrolling; vertical Tracks preserve horizontal scrolling.

ARIA: Track adds no role or ARIA attributes.

PropTypeDefault
asChildbooleanfalse
renderRenderProp-
Data attributeValues
[data-slot]"slider-track"
[data-orientation]"horizontal" | "vertical"
[data-disabled]Present when disabled

Range

Reports the selected start and end percentages and supplies the inline offset geometry for a visual fill. It is decorative.

PropTypeDefault
asChildbooleanfalse
renderRenderProp-
ARIA attributeValues
aria-hiddenAlways true
Data attributeValues
[data-slot]"slider-range"
[data-orientation]"horizontal" | "vertical"
[data-start]Normalized start percentage
[data-end]Normalized end percentage
[data-disabled]Present when disabled

Thumb

Renders one focusable slider control and connects its index to the matching value in Root. Range sliders need one Thumb for each value.

PropTypeDefault
indexnumber0
asChildbooleanfalse
renderRenderProp-
ARIA attributeValues
role"slider"
aria-valueminEffective minimum after the preceding thumb and required gap
aria-valuemaxEffective maximum before the following thumb and required gap
aria-valuenowCurrent thumb value
aria-valuetextResult from ariaValueText when provided
aria-orientationRoot orientation
aria-labelRoot label; numbered in a multi-thumb slider
aria-disabledtrue when Root is disabled
Data attributeValues
[data-slot]"slider-thumb"
[data-value]Current thumb value
[data-percent]Normalized current thumb percentage

Advanced compound parts can use useSliderContext and SliderContextProvider. Public range, percentage, snapping, closest-thumb, and offset helpers expose the same calculations used by the built-in parts.

Examples

Single Value

tsx
import { Slider } from "@flowstack-ui/atom";

export default function VolumeSlider() {
  return (
    <Slider.Root defaultValue={50} aria-label="Volume">
      <Slider.Track><Slider.Range /><Slider.Thumb /></Slider.Track>
    </Slider.Root>
  );
}

Range

tsx
import { Slider } from "@flowstack-ui/atom";

export default function PriceRange() {
  return (
    <Slider.Root defaultValue={[20, 80]} minStepsBetweenThumbs={2} aria-label="Price">
      <Slider.Track>
        <Slider.Range />
        <Slider.Thumb index={0} />
        <Slider.Thumb index={1} />
      </Slider.Track>
    </Slider.Root>
  );
}

Accessibility

Slider follows the WAI-ARIA slider pattern. Each Thumb is a focusable slider with its own value. Provide native aria-label, or use Field for the label and messages. ariaValueText can describe non-obvious values. Field state reaches every Thumb, read-only blocks editing, and uncontrolled values reset to defaultValue. Pointer cancellation restores the value present at pointer down and does not call onValueCommit. Lost pointer capture finalizes the latest value so normal browser capture release cannot make a completed click or drag jump backward. Only one pointer session can control a Slider at a time.

KeyDescription
ArrowRight / ArrowUpIncreases the focused thumb by step; ArrowRight decreases in horizontal RTL.
ArrowLeft / ArrowDownDecreases the focused thumb by step; ArrowLeft increases in horizontal RTL.
PageUpIncreases the focused thumb by largeStep.
PageDownDecreases the focused thumb by largeStep.
HomeMoves the focused thumb to min.
EndMoves the focused thumb to max.

Changelog

Unreleased

0.24.0

  • Added public Agent Knowledge for component selection, required composition, recurring mistakes, and validation.

0.19.4

  • Finalize the latest pointer value when capture is lost instead of restoring the pointer-down value; true pointercancel still rolls back without commit.

0.19.3

  • Exposed effective adjacent-thumb bounds through each Thumb's ARIA range.
  • Preserved non-slider-axis page scrolling and restored the pointer-down value without committing when a drag is cancelled or capture is lost.

0.5.0

  • Added Field disabled/read-only/invalid/required, generated naming and description integration, native aria-label, and uncontrolled reset.

0.2.0

  • Added Direction.Provider support for horizontal right-to-left pointer and keyboard behavior.
  • Fixed percent geometry so data-percent and inline percent offsets do not expose floating-point artifacts such as 55.00000000000001.

0.1.0

  • Initial Atom release.