Notch Slider
betaA discrete slider over named notches such as XS to XL, with a dark pill thumb that slides between them and a label that brightens.
- Forms
- 1 file
- 2 npm packages
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add notch-slidernpm packages installed: class-variance-authority, radix-ui.
import { NotchSlider } from "@/components/ui/notch-slider";Default
Demo
Spoken Names
<NotchSlider>
| Prop | Type | Default |
|---|---|---|
defaultValueInitial option when uncontrolled. Defaults to the second option. | string | — |
onValueChangeCalled with the option as the thumb moves. | (value: string) => void | — |
onValueCommitCalled when an interaction ends. | (value: string) => void | — |
optionLabelsSpoken names for the options, if the short labels are abbreviations. | readonly string[] | — |
optionsThe options, in order. Shown as the labels above the track. | readonly string[] | DEFAULT_OPTIONS |
size | "sm" | "md" | "lg" | "md" |
valueControlled selected option. | string | — |
wrapperClassNameClass for the wrapper that holds the labels and the track. | string | — |
Every prop of Radix UI’s Slider.Root, plus className.
Built on the Radix slider primitive with integer steps over the options: a role="slider" thumb whose aria-valuetext is the option's name (or a fuller spoken name from `optionLabels`, so "M" can be read as "Medium"), moved by Arrow keys, Home/End and pointer drag. It is named "Size" unless aria-label or aria-labelledby says otherwise. The visible labels are aria-hidden duplicates that pointer users can also click. The focus ring is drawn around the track, the active label is marked by weight as well as colour, and the whole control mirrors in right-to-left layouts. Under reduced motion the thumb jumps.
9/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — fails
- No fixed widths — passes