Slider
Slider component for selecting numeric values with support for ranges, steps, and multiple sizes.
import { Slider } from "@ninna-ui/forms"pnpm add @ninna-ui/formsRequires @ninna-ui/core (auto-installed) + CSS setup.
Usage
Import and use the Slider component in your application.
import { Slider } from "@ninna-ui/forms";
export default function Example() { return ( <Slider defaultValue={[50]} /> );}Basic
Basic slider with default value.
Variants
Slider with different display options including labels and marks.
Default
With Label
With Marks
Sizes
Slider comes in 3 sizes: sm, md, and lg.
Small
Medium
Large
Colors
Slider supports multiple color themes.
Range Slider
Slider with two thumbs for selecting a range.
Marks
Slider with marks on the track.
Orientation
Slider in horizontal and vertical orientations.
Inverted
Slider with inverted direction.
Min Steps Between
Range slider with minimum steps between thumbs.
Show Value
Slider with value display and custom formatting.
With Label
Slider with label and value display.
With Tooltip (Recipe)
Composition recipe showing how to add a tooltip that follows the thumb during drag.
Composition recipe: Wrap Slider with tooltip using pointer events on a container.
React Hook Form
Slider works with React Hook Form using the Controller pattern.
API Reference
Complete list of props for the Slider component.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'md' | Size of the slider |
color | 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'danger' | 'primary' | Color theme of the slider |
variant | 'solid' | 'outline' | 'solid' | Visual variant of the slider |
value | number[] | - | Controlled value (array for range sliders) |
defaultValue | number[] | [50] | Default value for uncontrolled usage |
onValueChange | (value: number[]) => void | - | Callback when value changes |
onValueCommit | (value: number[]) => void | - | Callback when value is committed (on mouse up) |
min | number | 0 | Minimum value |
max | number | 100 | Maximum value |
step | number | 1 | Step increment |
label | ReactNode | - | Label for the slider |
helperText | ReactNode | - | Helper text below slider |
showValue | boolean | false | Show current value |
showTooltip | boolean | false | Show tooltip on hover/drag |
formatValue | (value: number) => string | - | Format function for value display |
marks | SliderMark[] | boolean | - | Marks to display on the slider track |
orientation | 'horizontal' | 'vertical' | 'horizontal' | Orientation of the slider |
inverted | boolean | false | Whether the slider is inverted |
minStepsBetweenThumbs | number | - | Minimum steps between thumbs for range sliders |
invalid | boolean | false | Whether the slider is in an invalid state |
disabled | boolean | false | Whether the slider is disabled |
name | string | - | Name for form submission |
Accessibility
- Built on Radix UI Slider for full
WAI-ARIAcompliance - Uses
role="slider"witharia-valuemin,aria-valuemax, andaria-valuenow - Supports
aria-labelandaria-labelledbyvia props spread - Keyboard navigation: Arrow keys to adjust value, Home/End for min/max
- Labels are properly associated via
labelprop - Proper focus states with visible outlines