Xzero UI
Pro library

Elastic slider

A slider that stretches like rubber past its ends, with a swaying value tag and detents the thumb clicks into.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/elastic-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/elastic-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 { ElasticSlider } from "@/components/xzero/elastic-slider/elastic-slider";
import { Volume1, Volume2 } from "lucide-react";

export function VolumeControl() {
  const [volume, setVolume] = useState(60);
  return (
    <ElasticSlider
      label="Volume"
      value={volume}
      onValueChange={setVolume}
      marks={[0, { value: 50, label: "50%" }, 100]}
      format={value => `${value}%`}
      startIcon={<Volume1 size={16} />}
      endIcon={<Volume2 size={16} />}
    />
  );
}

API reference

ElasticSlider

A single value slider that stretches like rubber past either end, swells the thumb under the finger, hangs a value tag that sways with speed, and treats marks as detents the thumb clicks into.

PropTypeDefaultDescription
label (required)string–Visible label. It also names the thumb.
valuenumber–Controlled value. Leave it out for uncontrolled use.
defaultValuenumberminInitial value when uncontrolled.
onValueChange(value: number) => void–Called on every change while dragging or pressing keys.
onValueCommit(value: number) => void–Called once a drag is released, a key changes the value, or a mark label is clicked.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Value increment. Values snap to it.
largeStepnumber–Distance for PageUp, PageDown, and Shift with an arrow. Defaults to a tenth of the range.
marks(number | { value: number; label?: string })[]–Detents. A dragged thumb clicks into each one and holds for about 7px. Labelled marks print under the track and can be clicked.
format(value: number) => string–Formats the readout, the value tag, and aria-valuetext.
showValuebooleantrueShows the value beside the label. The tag over the thumb still appears while dragging or using keys.
startIconReactNode–Icon before the track. It is pushed outward when the track is pulled past the start.
endIconReactNode–Icon after the track. It is pushed outward when the track is pulled past the end.
namestring–Submits the value with a form through a hidden input.
disabledbooleanfalseBlocks pointer and keyboard input and removes the thumb from the tab order.
classNamestring–Extra class on the root.

Keyboard interactions

KeysAction
ArrowRight / ArrowUpIncreases by one step.
ArrowLeft / ArrowDownDecreases by one step.
Shift + Arrow / PageUp / PageDownMoves by largeStep.
Home / EndGoes to min or max. At a limit, the track stretches toward the press and snaps back.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Elastic slider: A slider that stretches like rubber past its ends, with a swaying value tag and detents the thumb clicks into. 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