Slider

Range input control for selecting a numeric value within a defined range. Supports labels, value display, and custom step intervals.

Setup

import { Slider } from '@fragments-sdk/ui';

Examples

Default

Basic slider with label

Loading preview...

With Value Display

Shows current value alongside the slider

Loading preview...

Custom Range

Custom min, max, and step values

Loading preview...

Controlled

Controlled slider with external state

Loading preview...

Drag Value Bubble

Shows a floating value bubble while the thumb is being dragged

Loading preview...

With Helper Text

Slider with helper text guidance

Loading preview...

Disabled

Disabled slider

Loading preview...

Props

PropTypeDefaultDescription
labelstringNot setLabel text
helperTextstringNot setHelper text shown below the slider
errorbooleanfalseShow error styling
valuenumberNot setControlled value
defaultValuenumberNot setDefault value for uncontrolled usage
onChangefunctionNot setCalled with new value when changed
onValueChangefunctionNot setAlias for onChange (Radix convention): (value: number) => void
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Step interval
showValuebooleanfalseDisplay current value
showValueOnDragbooleanfalseShow current value in a floating bubble while dragging the thumb
valueSuffixstringSuffix after value (e.g., "%", "px")
disabledbooleanfalseDisable the slider
namestringNot set
aria-labelstringNot setAccessible label when visible label is omitted
aria-labelledbystringNot setAccessible labelled-by relationship
aria-describedbystringNot setAccessible described-by relationship
idstringNot set

Usage Guidelines

When to use

  • Selecting a value from a continuous range
  • Volume or brightness controls
  • Price range filters
  • Settings that benefit from visual feedback

When not to use

  • Precise numeric input (use Input type="number")
  • Discrete options (use RadioGroup or Select)
  • Yes/no choices (use Switch)

Best practices

  • Always provide a label describing what the slider controls
  • Show the current value when precision matters
  • Use appropriate min/max values for the context
  • Consider step size for usability
Accessibility
  • Label is associated with the slider
  • Keyboard accessible with arrow keys
  • Current value is announced to screen readers
  • Uses native slider semantics