Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Range Slider
  3. API and Development

Range Slider

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import RangeSlider from @prepared911/ui/range-slider.
PropTypeDefaultNotes
labelLocalizedMessageVisible label above the track. Names the group unless aria-label or aria-labelledby is set. A name is required: label, aria-label or aria-labelledby.
aria-labelLocalizedMessageName of the group.
aria-labelledbystringId of the element that names the group.
showValuebooleantrue when label is setShows both live values at the inline end of the header row.
formatValue(value: number) => stringIntl in localeText of each value in the readout, the bubbles and aria-valuetext. The bubbles show it as plain text with no roll.
localestringruntime localeBCP 47 locale for the default format.
ticksreadonly SliderTick[]Marks along the track: { value, label? }. SliderTick is exported from Slider.
aria-describedbystringId of descriptive text, set on both thumbs.
startLabelLocalizedMessageRequired name of the start thumb.
endLabelLocalizedMessageRequired name of the end thumb.
valueReadonly<[number, number]>Controlled [start, end].
defaultValueReadonly<[number, number]>[min, max]Initial value when uncontrolled and the value a form reset restores.
onValueChange(value: [number, number], details: ChangeDetails<RangeSliderValueChangeReason>) => voidReasons: input-change, form-reset. Cancelable for input changes.
onFocusFocusEventHandler<HTMLElement>Called once when focus enters the slider from outside. Not called when focus moves between the two thumbs.
onBlurFocusEventHandler<HTMLElement>Called once when focus leaves the slider for somewhere outside, so a form library validates and marks the field touched once per visit. Not called when focus moves between the two thumbs.
minnumber0
maxnumber100
stepnumber1Must be greater than 0.
minStepsBetweenThumbsnumber0
orientationSliderOrientationHorizontal
disabledbooleanfalse
namestringBoth values submit under it, start first.
formstringId of the owning form.
classNamestringOn the host element.
refRef<HTMLDivElement>The host element.
data-*stringForwarded to the host element.
There is no style, size, variant, color, showInput, startValue or endValue. For numeric fields beside the track, compose two NumberFields with RangeSlider (see Slider usage and contract SL-4 / RS-5).
Exports
RangeSlider and the types RangeSliderProps, RangeSliderValue and RangeSliderValueChangeReason.
Props
NameTypeDefaultDescription
endLabelLocalizedMessage—Name of the end thumb, for example "Maximum price".
startLabelLocalizedMessage—Name of the start thumb, for example "Minimum price".
aria-describedbystring—Id of the element that describes the slider.
aria-labelLocalizedMessage—Accessible name of the group, for example "Price range". Accessible name of the group. Accessible name of the group, used instead of label.
aria-labelledbystring—Id of an element that also names the group. Id of the element that names the group. Id of an element that names the group, used instead of label.
classNamestring—Classes on the host element. Put overrides in @layer chroma.overrides.
defaultValuereadonly [start: number, end: number]—Initial [start, end] when uncontrolled, and the value a form reset restores. Defaults to [min, max].
disabledboolean—Ignores input, leaves the tab order, and omits both values from form submission.
formstring—Id of the form the values belong to when the slider sits outside it.
formatValue((value: number) => string)—Formats each value for the readout and the value bubbles, for example to add a unit. Defaults to Intl.NumberFormat in locale with the decimals of step, and the bubble's digits roll. With formatValue the bubble shows the text you return as plain text with no roll.
formatValueText((value: number) => string)—Formats each value for aria-valuetext only, when the spoken text should differ from the visible text (for example a duration read as words while the readout shows 1:30). Defaults to the formatValue text, or the default format.
labelLocalizedMessage—Visible label above the track, at the inline start of the header row. It also names the group unless aria-label or aria-labelledby is set. Visible label above the track. It names the group unless aria-label or aria-labelledby is set.
localestring—BCP 47 locale for the default value format. Defaults to the runtime locale, so a server rendered app that must match the client passes it explicitly. Ignored when formatValue is set.
maxnumber—Largest selectable value. Defaults to 100.
minnumber—Smallest selectable value. Defaults to 0.
minStepsBetweenThumbsnumber—Fewest steps that must separate the two thumbs. Defaults to 0.
namestring—Field name. The start and end values are submitted under it in that order.
onBlurFocusEventHandler<HTMLElement>—Called once when focus leaves the whole slider for somewhere outside it, such as the next field. It is not called when focus moves between thumbs, so a form library validates on blur once per visit.
onFocusFocusEventHandler<HTMLElement>—Called once when focus enters the slider from outside it. It is not called when focus moves between thumbs or a press on the track moves a focused thumb. Use it with onBlur to track whether the field was touched.
onValueChange((value: RangeSliderValue, details: ChangeDetails<RangeSliderValueChangeReason>) => void)—Called for every value change from pointer, keyboard, or form reset. Cancel the details to keep the old value.
orientationSliderOrientation—Axis of the slider. Defaults to {@link SliderOrientation.Horizontal}.
refRef<HTMLDivElement>—Ref to the host element.
showValueboolean—Whether the header row shows both live values at its inline end, start then end, in tabular numerals. Defaults to true when label is set and false otherwise; set it to true with no label for a readout on its own.
stepnumber—Increment between selectable values, counted from min. Must be greater than 0. Defaults to 1.
ticksreadonly SliderTick[]—Marks along the track, each with an optional label. They never move a thumb or change the value.
valuereadonly [start: number, end: number]—Controlled [start, end]. undefined on the first render is uncontrolled. Shown sorted and clamped into the range.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Range Slider / Usage
Next
Range Slider / Accessibility
On this page
Exports
Props
Storybook