Slider
Slider over native range inputs: thin accent track, white knob that lifts while held. One value or two for a range; keyboard, forms, touch and Field wiring come from the platform.
$40 – $180
"use client";import { useState } from "react";import { Field } from "@/components/ui/field";import { Slider } from "@/components/ui/slider";export function PriceFilter() { const [price, setPrice] = useState([40, 180]); return ( <Field label="Price" description={`$${price[0]} – $${price[1]}`}> <Slider value={price} onValueChange={setPrice} min={0} max={250} step={5} name="price" /> </Field> );}<Slider>
Slider over native range inputs: keyboard, forms, touch and screen readers work as the browser does. Thin accent track, white knob that lifts while held. Two values = range.
aria-describedbystringIds of hint or error text; Field fills it in.
aria-invalidbooleanError styling; Field sets it from
error.defaultValuenumber[]Values at first render (uncontrolled).
disabledbooleanBlocks dragging and keys.
idstringId of the first thumb; Field fills it in.
labelsstring[]Accessible names per thumb; defaults to "Minimum" / "Maximum" for a range.
maxnumberHighest value.
minnumberLowest value.
namestringSubmitted per thumb:
name(one value) ornametwice (range).onValueChange(value: number[]) => voidCalled with every thumb's value while dragging.
stepnumberIncrement for drag and arrow keys.
valuenumber[]One value, or two for a range (e.g. a price filter).
| Prop | Type | Default |
|---|---|---|
aria-describedbyIds of hint or error text; Field fills it in. | string | — |
aria-invalidError styling; Field sets it from | boolean | — |
defaultValueValues at first render (uncontrolled). | number[] | — |
disabledBlocks dragging and keys. | boolean | — |
idId of the first thumb; Field fills it in. | string | — |
labelsAccessible names per thumb; defaults to "Minimum" / "Maximum" for a range. | string[] | — |
maxHighest value. | number | — |
minLowest value. | number | — |
nameSubmitted per thumb: | string | — |
onValueChangeCalled with every thumb's value while dragging. | (value: number[]) => void | — |
stepIncrement for drag and arrow keys. | number | — |
valueOne value, or two for a range (e.g. a price filter). | number[] | — |
* required. Every component also takes className.