structyl

Slider

stable

An input where the user selects a value from within a given range.

Basic usage

Examples

Range slider

Pass two default values to create a range slider with two thumbs.

2080

Range and vertical sliders

Slider supports multiple thumbs, step intervals and orientation changes.

Semantic colors

Color prop tints the slider track and thumb to match semantic intent.

Features

  • Can be controlled or uncontrolled.
  • Supports multiple thumbs.
  • Supports keyboard and touch.
  • Supports a stepped interval and min/max.

Installation

bash
pnpm dlx structyl add slider

API Reference

Slider

A range input supporting one or more thumbs.

PropTypeDefault
valuenumber[]

Controlled value(s). One entry per thumb.

defaultValuenumber[]

Initial value(s) when uncontrolled.

[min]
onValueChange(value: number[]) => void

Called as the value changes.

onValueCommit(value: number[]) => void

Called when the value settles (pointer up / key release).

minnumber

Minimum value.

0
maxnumber

Maximum value.

100
stepnumber

Stepping interval.

1
minStepsBetweenThumbsnumber

Minimum steps between adjacent thumbs.

0
orientation'horizontal' | 'vertical'

Slider axis.

'horizontal'
disabledboolean

Disable the slider.

false
dir'ltr' | 'rtl'

Reading direction.

classNamestring

Additional Tailwind classes, merged with the component defaults.

Keyboard interactions

Adheres to the WAI-ARIA design pattern .

KeyDescription
ArrowRight / ArrowUpIncreases the value by the step amount.
ArrowLeft / ArrowDownDecreases the value by the step amount.
Home / EndSets the value to its minimum / maximum.
PageUp / PageDownIncreases / decreases by a larger step.
Slider | structyl