FORMA Docs

Slider

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

import { Slider } from "@/forma/arc/slider/slider";
Base

In FORMA

  • Liegt in kit/arc/slider und ist über @/forma/arc/slider/slider erreichbar.
  • Farbe, Ecken, Höhen, Abstände, Tiefe, Schrift und Tempo kommen aus der Richtung (core/arc-bridge.ts); Arc behält Verhalten, Tastatur und Federn.

When to use

  • Approximate values like volume, opacity, or a price range.
  • Ranges with two thumbs, labelled marks, and a formatted readout.

When not to use

  • Use number-field when the exact number matters.
  • Use progress to show a value people cannot change.

Usage

import { Slider } from "@/forma/arc/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

  • Each thumb is role="slider" with aria-valuemin, aria-valuemax, aria-valuenow, aria-valuetext from format, and aria-orientation.
  • Thumbs are named by label, or by thumbLabels for ranges.
  • The readout, bubble, and marks are aria-hidden because the thumbs carry the value.

Motion

  • Released drags carry a little momentum before snapping; the bubble springs up over an active thumb and digits roll in the readout. At a limit the thumb strains toward the key press and springs back.
  • Reduced motion removes momentum, the strain, and digit rolling, and turns off CSS transitions.

Responsive behavior

  • It fills its column; the track uses touch-action pan-y, so horizontal drags move the thumb while vertical swipes scroll the page.
  • On coarse pointers the value bubble sits higher so the finger does not cover it.
  • The bubble and end mark labels clamp inside the track so they never overflow the edges.

Performance

  • Drags write motion values with pointer capture, so the thumb follows 1:1 without React re-renders per frame.
  • onValueChange fires on every step; put fetching or heavy work in onValueCommit.

Notes for AI

  • Use for approximate values and ranges like volume, price filters, or opacity. Use number-field when the exact number matters.
  • Controlled or uncontrolled; pass a tuple for a range. Put heavy work such as fetching in onValueCommit, not onValueChange.
  • Pass name to submit through hidden inputs. Exported as both named and default.

Also in sliders

  • Elastic slider: A slider that stretches like rubber past its ends, with a swaying value tag and detents the thumb clicks into.
  • Range histogram slider: A price range over a live histogram of the data, lighting the bars inside the range and settling on bar edges.

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://uiarc.dev/llms.txt

Komponente und Text: Arc UI (MIT, uiarc.dev), angepasst für FORMA.