Slider
freeSlider selects a number or a range by dragging a thumb along a track.
Installation
Add this component with the NateUI CLI.
Examples
Range
Disabled
Tooltips
Show on hover
Always visible
Custom content
Marks
Capsule
Step
Min And Max
Custom Color
Controlled
Value: 50
Range: 20 – 50
API
Slider selects a single value; Slider.Range selects a [start, end] pair with two thumbs. Both are uncontrolled with defaultValue or controlled with value and onChange, and both accept native div props.
Slider
| Prop | Description | Type | Default |
|---|---|---|---|
value | Current value in controlled mode. | number | - |
defaultValue | Initial value when uncontrolled. | number | 0 |
onChange | Fires with the new value while the value changes. | (value: number) => void | - |
onDraggingStop | Fires with the final value when a drag or key change ends. | (value: number) => void | - |
min | Lowest selectable value. | number | 0 |
max | Highest selectable value. | number | 100 |
step | Increment applied while dragging or using arrow keys. | number | 1 |
marks | Reference points rendered under the track. | SliderMark[] | [] |
stepOnMarks | Snap the thumb to mark values instead of stepping by step. | boolean | - |
variant | Visual treatment for the slider. capsule uses the thicker rail and embedded marks. | SliderVariant | 'default' |
precision | Decimal places kept in the reported value. | number | derived from step |
tooltip | Tooltip content, or a function of the current value. | SliderTooltip | identity |
showTooltipOnHover | Show the tooltip on hover, drag, and focus. | boolean | false |
alwaysShowTooltip | Keep the tooltip visible at all times. | boolean | false |
disabled | Prevent interaction and dim the track. | boolean | false |
thumbAriaLabel | Accessible label for the thumb. | string | - |
name | Name of the hidden input holding the value. | string | - |
inputProps | Props spread onto the hidden input. | ComponentPropsWithoutRef<'input'> | - |
classNames | Class names for individual slider parts. | SliderClassNames | {} |
className | Class names for the root element. | string | - |
ref | Ref forwarded to the root element. | Ref<HTMLDivElement> | - |
...nativeProps | Native props for the root div. | ComponentProps<'div'> | - |
Slider.Range
| Prop | Description | Type | Default |
|---|---|---|---|
value | Current range in controlled mode. | RangeSliderValue | - |
defaultValue | Initial range when uncontrolled. | RangeSliderValue | - |
onChange | Fires with the new range while it changes. | (value: RangeSliderValue) => void | - |
onDraggingStop | Fires with the final range when a drag or key change ends. | (value: RangeSliderValue) => void | - |
min | Lowest selectable value. | number | 0 |
max | Highest selectable value. | number | 100 |
minRange | Smallest allowed distance between the two thumbs. | number | 0 |
maxRange | Largest allowed distance between the two thumbs. | number | - |
step | Increment applied while dragging or using arrow keys. | number | 1 |
marks | Reference points rendered under the track. | RangeSliderMark[] | [] |
stepOnMarks | Snap thumbs to mark values instead of stepping by step. | boolean | - |
variant | Visual treatment for the range slider. capsule uses the thicker rail and embedded marks. | SliderVariant | 'default' |
precision | Decimal places kept in the reported values. | number | derived from step |
tooltip | Tooltip content, or a function of a single thumb value. | SliderTooltip | identity |
showTooltipOnHover | Show tooltips on hover, drag, and focus. | boolean | false |
alwaysShowTooltip | Keep both tooltips visible at all times. | boolean | false |
disabled | Prevent interaction and dim the track. | boolean | false |
thumbArialLabelStart | Accessible label for the start thumb. | string | - |
thumbAriaLabelEnd | Accessible label for the end thumb. | string | - |
name | Base name for the hidden -from and -to inputs. | string | - |
inputProps | Props spread onto both hidden inputs. | ComponentPropsWithoutRef<'input'> | - |
classNames | Class names for individual slider parts. | RangeSliderClassNames | {} |
className | Class names for the root element. | string | - |
ref | Ref forwarded to the root element. | Ref<HTMLDivElement> | - |