Dashral Pro is on the wayGet 30% off at launch

Dashral

Slider

Pick a value or a range by dragging a thumb.

$ pnpm dlx shadcn@latest add https://dashral.com/r/slider.json
60%

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/slider.json

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:

components.json
{
  "registries": {
    "@dashral": "https://dashral.com/r/{name}.json"
  }
}

Then add components by name:

$ pnpm dlx shadcn@latest add @dashral/slider

Usage

example.tsx
import { Slider } from "@/components/dashral/slider"

<Slider label="Price" defaultValue={[20, 80]} thumbLabels={["Minimum price", "Maximum price"]} />

Examples

Range

Two values render two thumbs; thumbLabels names each one.

$49 – $199

Price filter

A histogram over the range lights up the bars inside it; the count and the min/max fields follow.

Price

81 products

$
$

API reference

Slider

Also takes every prop of Radix Slider(opens in a new tab).

PropTypeDefault
value / defaultValuenumber[]

One value, or two for a range.

—
onValueChange(value: number[]) => void

Called with the new value.

—
min / max / stepnumber0 / 100 / 1
color"primary" | "neutral" | "info" | "success" | "warning" | "destructive" | "highlight"

The filled part and the thumbs.

"primary"
thumbLabelsstring[]

Each thumb's name, for a range: ["Minimum price", "Maximum price"].

—
labelReactNode

Shown above, linked to the control.

—
descriptionReactNode

A hint under the control.

—
errorboolean | ReactNode

true shows the error style; a message also shows under the control.

—
labelActionReactNode

At the end of the label's row, e.g. a “Forgot password?” link or the current value.

—
withAsteriskboolean

Marks the label with an asterisk, e.g. alongside required.

false
classNames{ root, label, description, error, track, range, thumb }

Classes for each part.

—

Keyboard

KeysAction
Arrow keysOne step
Page UporPage DownBigger steps
HomeorEndMin / max

Accessibility

  • Each thumb is role="slider" with its value, named by the label (or aria-label); a range names each thumb with thumbLabels.

Motion

  • The thumb grows a little while you drag it.