Skip to content

Design system

Documentation

DesignComponents / Slider

Components / Slider

Beta

Slider

Select a bounded numeric value or range while preserving native slider semantics and keyboard behavior.

On this page

Examples

Single value

Use the thumb, keyboard, or track to select a bounded value.

Volume
40

Volume slider

Range with marks

Two thumbs keep a selected interval; labels name each endpoint for assistive technology.

Price range
100 – 350

Price range slider with marks

Disabled slider

Keep a fixed value visible when the feature does not allow adjustment.

Locked allocation
65

Disabled allocation slider

Try the slider

Adjust the value and compare its disabled state; the marks remain tied to the same range.

Opacity
65

Slider property playground

When to use

Use Slider when the user can choose an approximate point or interval within a known numeric range. Use InputNumber when an exact value is easier to type.

Usage

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

<Slider label="Price range" min={0} max={500} step={25} defaultValue={[100, 350]} thumbLabels={["Minimum price", "Maximum price"]} />

Behavior

  • A number value creates one thumb; a two-number array creates a range with two thumbs.
  • Arrow keys adjust the focused thumb by step; Page Up/Down use the underlying slider's larger step behavior.
  • marks are decorative reference points and do not snap or change the allowed values.
  • All value changes are reported to the feature; Slider performs no formatting or business validation beyond native range constraints.

API

Component API
PropTypeDefaultDescriptionConstraints
labelstringrequiredVisible name for every thumb in the control.Provide a specific label; use thumbLabels to name each range endpoint.
value / defaultValuenumber | readonly number[]uncontrolled 0Controlled value or initial value; two numbers create a range.Use a number for one thumb and exactly two ordered numbers for a range.
onValueChange(value: number | readonly number[]) => void—Receives updates during pointer or keyboard interaction.Update controlled state in the feature.
min / max / stepnumber0 / 100 / 1Numeric range and movement increment.Choose a step that divides the range cleanly where possible.
marksreadonly { value: number; label?: ReactNode }[]—Optional visual reference labels within the range.Only finite marks inside min and max are rendered; they do not affect snapping.
thumbLabelsreadonly string[]—Accessible names for each thumb in a range.Provide one stable label per thumb when their roles differ.
disabled / name / form / format / localeBase UI Slider root propsfalse / — / — / — / runtime localeForwards native interaction, form, and formatting options.Feature-owned formatting remains outside the component unless native format/locale is explicitly configured.

Tokens

Component tokens
TokenRoleEffective valueUsage
--color-action-primary / --color-bg-subtleTrack and fillSemantic rolesShows the selected region consistently across themes.
--size-control-md / --focus-ring-*Thumb and focusShared control scale and focus ringKeeps the target visible and keyboard-operable.

Accessibility

The visible label names the slider. A range uses thumbLabels to distinguish endpoints. Keyboard users can focus each thumb and adjust it with arrow keys. Marks are decorative; the current value is rendered as an output next to the label.

Do and don’t

Do

Show the current value and provide an InputNumber alternative when exact entry matters.

Don’t

Use marks as if they were selectable stops unless the configured step actually matches them.

  • InputNumber accepts precise numeric entry.
  • RadioGroup selects one of a few discrete alternatives.
  • Field provides supporting labels and validation.