Talisman LogoTalisman Logo Design System
Browse documentation
Components

Slider

Selects a number, or a range, by dragging a thumb along a track, for values where an approximate position is enough.

Stableimport { Slider } from "@repo/ui/slider";Source
Limite de confiança40%
orientation
<Slider orientation="horizontal" />

The slider has no built-in label or value readout. Place a label and the current value next to it, as the examples do.

When to use

  • To set a threshold or a limit where the exact number matters less than the position, such as the minimum confidence of an extractor.
  • To select a range between two values, such as a case value range.
  • When the user benefits from seeing the minimum and maximum of the scale.

When not to use

  • An exact number the user already knows. Use an Input with a number type.
  • A choice between a few named options. Use Radio group.
  • An on or off setting. Use Switch.
  • A date interval. Use a date range picker.

Examples

Single value

Pair the slider with a label and the current value.

Confiança mínima do extrator80%

Range

Pass two numbers in value to get two thumbs.

Faixa de valor da causa (R$ mil)20 – 70

States

Confiança mínima do extrator60%

Content

  • Name what the value controls: “Confiança mínima do extrator”, not “Valor”.
  • Show the unit next to the value: “80%”, “R$ 20 – 70 mil”.
  • Use step to match the precision people need. A step of 5 is easier to hit with a mouse than 1.

Accessibility

  • Built on Radix Slider. Each thumb has role="slider" with aria-valuemin, aria-valuemax, aria-valuenow and aria-orientation.
  • Keyboard: arrow keys change the value by step, Page Up and Page Down by larger steps, and Home and End jump to the minimum and maximum.
  • A single thumb needs an accessible name, and the component does not provide one. See Known issues.
  • onValueCommit fires once when the user releases the thumb. Use it to save, and use onValueChange only to update the interface while dragging.

Code

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

const [value, setValue] = useState([80]);

<Slider max={100} min={0} onValueChange={setValue} step={5} value={value} />;

Props

Slider
PropTypeDefaultDescription
disabledbooleanfalseDisables dragging and keyboard input
maxunknown100Highest value on the track
minunknown0Lowest value on the track
onValueChange(value: number[]) => void—Called on every change while dragging
onValueCommit(value: number[]) => void—Called once when the user releases the thumb
orientation"horizontal" | "vertical"horizontalDirection of the track
stepunknown1Distance between selectable values
valuenumber[]—Controlled value. One number per thumb; two numbers make a range

Every other prop of the Radix Slider root, such as name, inverted and minStepsBetweenThumbs, is forwarded.

Known issues

Issue Effect
aria-label and aria-labelledby are spread on the root, but Radix reads the name from the thumb. The thumb is rendered without it. A single-thumb slider has no accessible name. Screen readers announce only “slider” and the value.
With two thumbs Radix names them “Minimum” and “Maximum” in English. The package cannot be translated by apps, and the names do not say what the range measures.
The thumb is h-3 w-3 (12px). Below the 24px minimum hit target. Hard to grab with a mouse on older screens.
The thumb styles disabled with disabled:opacity-50, but the thumb is a span, so :disabled never matches. Radix sets data-disabled. A disabled slider looks identical to an enabled one.
Range and Track both use border-secondary and the range has no fill. The selected portion cannot be told apart from the rest of the track.
The focus ring uses ring-ring and ring-offset-background. The Tailwind config only defines old-ring and old-background. Neither class generates a style. The ring color and the offset fall back to Tailwind defaults.
Edit this page on GitHub