Example#
Usage#
Use a slider to pick a value or a range where the rough position matters more than the exact figure: a budget, a team size, a timeline. For an exact number someone already knows, an Input with type="number" is faster.
- Default draws an 8 px track, a 28 px disc thumb and a value chip above the thumb while it moves or holds focus.
variant="ruler"is the estimator's printer's ruler: minor ticks every step, labelled major ticks atmarks, and a carriage thumb that holds the formatted value.- Ranges. Pass
[lo, hi]as the value for two thumbs; each thumb gets its own name throughthumbLabels. formatprints the value everywhere it shows, in the chip, the carriage andaria-valuetext, so a screen reader hears "$6,500", not "6500".- Phones. The thumb's hit area is 44 px; below 30rem the ruler drops minor ticks and labels every other major one.
Anatomy#
- RulerBaseline, minor ticks every step, major ticks at the marks.
.mk-slider-ruler - CarriageThe ruler's thumb: a plate holding the formatted value.
.mk-slider-carriage - Mark labelsTabular figures in the label role.
.mk-slider-marks
Volume#
Reading layer: the track, the thumb and the ruler print the same at every volume.
Quiet
Studio
Press
Rave
Content#
- The label names the quantity and its unit lives in
format: "Budget" with "$6,500", never "Budget ($)". - Mark only the values people reason with: the ends and one or two round numbers.
- Prices stay literal (D-I2): a slider that sets a budget shows the real figure, not "a bit" or "loads".
Do and don't#
Do
Don't
Your estimate
$3,200 to $4,800
Accessibility#
- Each thumb is a
sliderwitharia-valuetextfromformat, so prices are read as prices. - Inside Field the thumbs take the field's label; range thumbs add "minimum" and "maximum".
- Thumb hit areas are 44 px.
| Keys | What happens |
|---|---|
| Tab | Moves focus to the thumb (each thumb of a range is its own stop) |
| LeftorRight,UporDown | Move one step |
| Page UporPage Down | Move one large step (10 steps by default) |
| HomeorEnd | Jump to the minimum or the maximum |
The colour pairs it prints, with their contrast on both papers:
| Text | Surface | Role | Bone | Night |
|---|---|---|---|---|
--mk-on-slab | --mk-slab | label | 16.49:1 · Lc 98.7, passes | 16.21:1 · Lc 95.1, passes |
--mk-text | --mk-surface | ui | not in this look | not in this look |
--mk-text | --mk-surface-raised | ui | not in this look | not in this look |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
min | number | none | |
max | number | none | |
step | number | none | |
largeStep | number | 10 | PageUp / PageDown (default 10 × step). |
value | SliderValue | none | |
defaultValue | SliderValue | none | |
onValueChange | ((value: SliderValue) => void) | none | |
onValueCommitted | ((value: SliderValue) => void) | none | When a drag or key press ends. |
format | Intl.NumberFormatOptions | ((value: number) => string) | none | Drives the value chip, the carriage and `aria-valuetext` (prices stay literal, D-I2): a function for client callers, or `Intl.NumberFormat` options (serialisable, so a server component can pass them). |
locale | string | the page's | The locale for `Intl.NumberFormat` options (default the page's). |
marks | readonly SliderMark[] | none | Major ticks (ruler) or points under the track (default). |
name | string | none | The form value's name (hidden inputs post with the form). |
variant | "default" | "ruler" | none | |
disabled | boolean | none | |
label | string | none | The accessible name when the slider is not inside `Field`. |
thumbLabels | readonly [string, string] | "minimum" and "maximum" | Range thumbs' names after the label (default "minimum" and "maximum"). |
id | string | none | From `Field`: the thumbs take `{id}-label` as their name. |
aria-labelledby | string | none | |
aria-describedby | string | none | |
aria-invalid | "false" | "true" | boolean | none | |
ref | Ref<HTMLDivElement> | none | |
className | string | none | |
style | CSSProperties | none |
Tokens#
System tokens (26)
--mk-border--mk-border-thick--mk-control-rule--mk-disabled--mk-display-family--mk-focus--mk-font-text--mk-on-slab--mk-radius-chip--mk-radius-pill--mk-rule--mk-selected--mk-slab--mk-space-1--mk-surface-raised--mk-surface-sunken--mk-target-touch--mk-text--mk-track-numeral-s--mk-type-label-leading--mk-type-label-size--mk-type-label-weight--mk-type-numeral-s-leading--mk-type-numeral-s-size--mk-wd-numeral-s--mk-wght-numeral-s
Its own properties (6)
--mk-slider-carriage-pad--mk-slider-chip-pad-block--mk-slider-chip-pad-inline--mk-slider-inset--mk-slider-thumb--mk-slider-track
Changelog#
Arrived in 0.1.0.
- The reading layer's controls, overlays, forms and visitor prefs (P2-T1 to P2-T5): every Button is the comic hit key, with IconButton, Link and Tooltip; Input, Textarea, Select, Checkbox and CheckboxGroup, Radio and RadioGroup, Switch, Slider with the ruler, RulerReadout and SegmentedControl; Dialog, Drawer, NavSheet, Tabs, Disclosure, Faq and faqJsonLd on Base UI 1.9 where the platform falls short; Field, Fieldset, Form with the site's inline validation, ErrorSummary, Callout, Honeypot, FormTimestamp and QuoteForm; PrefsScript under 1 KB, usePref and setPref with cross-tab sync, ThemeToggle and the visitor VolumeDial; VisuallyHidden.