Slider API

API documentation for Slider component

SliderRoot#

Props#

Defines valid properties in Slider component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: SliderRootInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: SliderRootInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<SliderRootPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: SliderRootInstance) => ReactNode)
null
The children to render.
disabledboolean
false
When present, it specifies that the element should be disabled.
invalidboolean
false
When present, it specifies that the element should be invalid.
onValueChange(event: SliderRootChangeEvent) => void
null
Callback fired when the ToggleButton's pressed state changes.
onValueChangeEnd(event: SliderRootChangeEvent) => void
null
Callback fired when the pointer interaction ends.
valuenumber | number[]
null
Value of the component.
defaultValuenumber | number[]
null
The default value for the input when not controlled by `value` .
minnumber
0
Mininum boundary value.
maxnumber
100
Maximum boundary value.
orientation"horizontal" | "vertical"
horizontal
Orientation of the slider.
stepnumber
1
Step factor to increment/decrement the value.
minStepsBetweenThumbsnumber
0
Minimum steps between thumbs.
readOnlyboolean
false
Whether the component is read-only.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in Slider component.

nametypedefaultdescription
valuenumber | number[]
null
Value of the component.
isDraggingboolean
null
Whether the slider is being dragged.

Exposes#

Defines the methods and properties exposed by Slider component.

nametypedefaultdescription
stateuseSliderState
null
The state of the useSlider.
range() => boolean
null
Determines if the slider is in range mode.
getThumbValue(index: number) => number
null
Returns the value for a specific thumb.
getRangeStyle() => CSSProperties
null
Returns the style object for the range element.
getThumbStyle(index: number) => CSSProperties
null
Returns the style object for a thumb.
setRootRef(node: HTMLDivElement) => void
null
Sets the root element ref.
onTrackPointerDown(event: PointerEvent<HTMLDivElement>) => void
null
Pointer handlers for the root element.
onTrackPointerMove(event: PointerEvent<HTMLDivElement>) => void
null
Pointer handlers for the root element.
onTrackPointerUp(event: PointerEvent<HTMLDivElement>) => void
null
Pointer handlers for the root element.
updateValueFromPointer(event: PointerEvent<HTMLDivElement>) => void
null
Updates value from a pointer position without dragging.
onThumbPointerDown(event: PointerEvent<HTMLDivElement>, index: number) => void
null
Pointer handlers for thumbs.
onInputChange(event: ChangeEvent<HTMLInputElement>, index: number) => void
null
Input change handler for thumbs.
onInputFocus(event: FocusEvent<HTMLInputElement>, index: number) => void
null
Input focus handler for thumbs.
onInputBlur(event: FocusEvent<HTMLInputElement>, index: number) => void
null
Input blur handler for thumbs.

Events#

Event fired when the Slider's value changes.

nametypedescription
valuenumber | number[]The pressed state of the ToggleButton.
originalEventSyntheticEventThe original event that triggered the change.

Interfaces#

Defines passthrough(pt) options of Slider component.

nametypedefaultdescription
rootSliderRootPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.
rangeSliderRootPassThroughType<HTMLAttributes<HTMLSpanElement>>
null
Used to pass attributes to the range's DOM element.
thumbSliderRootPassThroughType<HTMLAttributes<HTMLSpanElement>>
null
Used to pass attributes to the thumb's DOM element.

Types#

Instance of Slider component.

values
ComponentInstance<SliderRootProps, SliderRootState, SliderRootExposes>

SliderRange#

Props#

Defines valid properties in SliderRange component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: SliderRangeInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: SliderRangeInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<SliderRangePassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: SliderRangeInstance) => ReactNode)
null
The children to render.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

Exposes#

Defines the methods and properties exposed by SliderRange component.

nametypedefaultdescription
sliderSliderRootInstance
null
The Slider component instance.

Interfaces#

Defines passthrough(pt) options of SliderRange component.

nametypedefaultdescription
rootSliderRangePassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of SliderRange component.

values
ComponentInstance<SliderRangeProps, SliderRangeState, SliderRangeExposes>

SliderThumb#

Props#

Defines valid properties in SliderThumb component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: SliderThumbInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: SliderThumbInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<SliderThumbPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: SliderThumbInstance) => ReactNode)
null
The children to render.
indexnumber
0
Index of the thumb.
tabIndexnumber
0
Index of the element in tabbing order.
ariaLabelstring
null
Establishes a string value that labels the component.
ariaLabelledbystring
null
Establishes relationships between the component and label(s) where its value should be one or more element IDs.
namestring
null
Name attribute of the input.
inputIdstring
null
Id of the input.
inputStyleCSSProperties
null
Style of the input element.
inputClassNamestring
null
Style class of the input element.
disabledboolean
false
When present, it specifies that the element should be disabled.
readOnlyboolean
false
When present, it specifies that the element should be read-only.
invalidboolean
false
When present, it specifies that the element is invalid.
requiredboolean
null
When present, it specifies that the element is required.
onFocusFocusEventHandler<HTMLInputElement>
null
Callback fired on focus.
onBlurFocusEventHandler<HTMLInputElement>
null
Callback fired on blur.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

Exposes#

Defines the methods and properties exposed by SliderThumb component.

nametypedefaultdescription
sliderSliderRootInstance
null
The Slider component instance.

Interfaces#

Defines passthrough(pt) options of SliderThumb component.

nametypedefaultdescription
rootSliderThumbPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of SliderThumb component.

values
ComponentInstance<SliderThumbProps, SliderThumbState, SliderThumbExposes>

useSlider#

Props#

Defines valid properties in useSlider.

nametypedefaultdescription
valuenumber | number[]
null
Value of the component.
defaultValuenumber | number[]
null
The default value for the input when not controlled by `value` .
minnumber
0
Mininum boundary value.
maxnumber
100
Maximum boundary value.
orientation"horizontal" | "vertical"
horizontal
Orientation of the slider.
stepnumber
1
Step factor to increment/decrement the value.
minStepsBetweenThumbsnumber
0
Minimum steps between thumbs.
onValueChange(event: useSliderChangeEvent) => void
null
Callback fired when the ToggleButton's pressed state changes.
onValueChangeEnd(event: useSliderChangeEvent) => void
null
Callback fired when the pointer interaction ends.
disabledboolean
false
Whether the component is disabled.
readOnlyboolean
false
Whether the component is read-only.

State#

Defines valid state in useSlider.

nametypedefaultdescription
valuenumber | number[]
null
Value of the component.
isDraggingboolean
null
Whether the slider is being dragged.

Exposes#

Defines the methods and properties exposed by useSlider.

nametypedefaultdescription
stateuseSliderState
null
The state of the useSlider.
range() => boolean
null
Determines if the slider is in range mode.
getThumbValue(index: number) => number
null
Returns the value for a specific thumb.
getRangeStyle() => CSSProperties
null
Returns the style object for the range element.
getThumbStyle(index: number) => CSSProperties
null
Returns the style object for a thumb.
setRootRef(node: HTMLDivElement) => void
null
Sets the root element ref.
onTrackPointerDown(event: PointerEvent<HTMLDivElement>) => void
null
Pointer handlers for the root element.
onTrackPointerMove(event: PointerEvent<HTMLDivElement>) => void
null
Pointer handlers for the root element.
onTrackPointerUp(event: PointerEvent<HTMLDivElement>) => void
null
Pointer handlers for the root element.
updateValueFromPointer(event: PointerEvent<HTMLDivElement>) => void
null
Updates value from a pointer position without dragging.
onThumbPointerDown(event: PointerEvent<HTMLDivElement>, index: number) => void
null
Pointer handlers for thumbs.
onInputChange(event: ChangeEvent<HTMLInputElement>, index: number) => void
null
Input change handler for thumbs.
onInputFocus(event: FocusEvent<HTMLInputElement>, index: number) => void
null
Input focus handler for thumbs.
onInputBlur(event: FocusEvent<HTMLInputElement>, index: number) => void
null
Input blur handler for thumbs.

Events#

Event fired when the Slider's value changes.

nametypedescription
originalEventEThe original event that triggered the change.
valuenumber | number[]The pressed state of the ToggleButton.

Types#

Instance of useSlider headless.

values
HeadlessInstance<useSliderProps, useSliderState, useSliderExposes>