Xzero UI
Pro library

Slider

Pick a value or a range on a track that follows your finger.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/slider
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/slider

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { Slider } from "@/components/xzero/slider/slider";

export function PriceFilter() {
  const [range, setRange] = useState<[number, number]>([20, 80]);
  return (
    <Slider
      label="Price"
      value={range}
      onValueChange={setRange}
      step={5}
      format={(v) => `$${v}`}
      thumbLabels={["Minimum price", "Maximum price"]}
    />
  );
}

API reference

Slider

A single or range slider with momentum dragging, marks, a value bubble, and a rolling readout.

PropTypeDefaultDescription
label (required)string–Visible label; names the thumbs unless thumbLabels is set.
valuenumber | [number, number]–Controlled value. A pair renders a range with two thumbs.
defaultValuenumber | [number, number]–Initial value when uncontrolled.
onValueChange(value: T) => void–Called on every step while dragging or pressing keys.
onValueCommit(value: T) => void–Called once when a drag is released or a key changes the value.
minnumber0Lower bound.
maxnumber100Upper bound.
stepnumber1Increment.
largeStepnumbera tenth of the rangeDistance for PageUp, PageDown, and Shift with an arrow.
marks(number | { value: number; label?: string })[]–Ticks on the track; labelled marks print under it and are clickable.
minStepsBetweenThumbsnumber0Closest two range thumbs may sit, in steps.
format(value: number) => string–Formats the readout, bubble, and spoken value.
showValuebooleantrueShow the readout beside the label.
thumbLabels[string, string]–Accessible names for the two range thumbs.
startReactNode–Content before the track, such as an icon.
endReactNode–Content after the track.
namestring–Submits the value with a form, one hidden input per thumb.
disabledboolean–Disables dragging and keys.
classNamestring–Added to the root.

Keyboard interactions

KeysAction
ArrowRight / ArrowUpIncreases by step.
ArrowLeft / ArrowDownDecreases by step.
Shift + Arrow / PageUp / PageDownMoves by largeStep.
Home / EndMoves to the lowest or highest allowed value for that thumb.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in sliders

Guidance for AI tools

Slider: Pick a value or a range on a track that follows your finger. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components