Default
Drag the knob, or focus it and use the arrow keys, Home, End and Page Up / Down. The marker range follows the value; nothing is redrawn while you drag.
Pick a number, or two, by dragging a paper knob along a hand-ruled groove. The range is one marker pass drawn full length and revealed by a CSS clip, so nothing is redrawn while you drag. Ticks, a highlighter or blue-felt range, vertical, and range sliders. Radix Slider underneath.
npx shadcn@latest add @wobko/slider第一次使用?先把 registry 加进 components.json。 如何安装
Drag the knob, or focus it and use the arrow keys, Home, End and Page Up / Down. The marker range follows the value; nothing is redrawn while you drag.
Two values make a range slider. `ticks` hangs pencil marks under the groove (one per step, or a number of intervals); `tone` swaps the marker for a highlighter or blue felt.
A mixing desk: `orientation="vertical"` stands the groove up; the range grows from the bottom. The last fader is disabled.
Three controlled sliders in a panel, each with its own readout, and a reset that puts every knob back where it started. The values are the only state; the drawings do not change.
Official `slider-demo`: a single value from 0 to 100 at 60% width, written as a component that forwards its props (so a caller can pass `defaultValue`, `max`, `step` or `className`). The marker range is drawn once and clipped to the value; the only addition is an `aria-label`, which the knob needs.
Radix Slider.Root with the track, range and one thumb per value already inside. Give it one value for a plain slider, two or more for a range slider. The three drawings are separate hosts, and the range host is clipped to the values (the drawing never sees them).
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value / defaultValue / onValueChange / onValueCommit | number[] | - | Controlled or uncontrolled values. The number of values is the number of thumbs. Without either, one thumb at `min`. |
| min / max / step | number | 0 / 100 / 1 | The span and its granularity. Thumbs snap to `step`. |
| orientation | "horizontal" | "vertical" | "horizontal" | Vertical grows from the bottom (from the top when `inverted`). |
| minStepsBetweenThumbs | number | 0 | Range sliders: keep the thumbs this many steps apart. |
| ticks | boolean | number | - | Pencil tick marks hanging under the groove: `true` marks every step when there are 20 or fewer, else ten intervals; a number is that many intervals. The end marks are longer. |
| getValueText | (value: number, index: number) => string | - | aria-valuetext of each thumb: what a screen reader says instead of the bare number ("12 px", "72 %", "Soft"). Use it whenever you show the value with a unit next to the slider. |
| tone | "marker" | "hi" | "blue" | "marker" | What colors the range: terracotta marker, highlighter or blue felt. |
| inverted / dir | boolean / "ltr" | "rtl" | - | Reverse the direction the values grow in; right-to-left starts at the right. |
| disabled | boolean | - | Dashed pencil groove, graphite range and a dashed knob. Not focusable. |
| name / form | string | - | Names the hidden inputs Radix adds inside a form (one per thumb, `name[]` for a range). |
| aria-label / aria-labelledby / aria-describedby | string | - | Names and describes the slider: on the thumb for one value, on a role=group Root for several (thumbs keep Radix's Minimum / Maximum). |
| aria-invalid | boolean | "true" | "false" | - | On every thumb (that is where the role=slider is), and the groove's two pulls and the knob's loop are drawn in red pencil. FormControl sets it for you. |
| seed | string | number | - | Pins the hand: the same seed always draws the same slider. Default: derived from useId(). |
CLI 会复制进你项目的文件。
正在加载源码