Officina UI
Components

Slider

Controlled single-thumb slider for picking a numeric value within a min/max range.

Slider lets the user pick a number by dragging a thumb along a track. It is controlled: value is a one-entry array and onValueChange returns the updated array as the thumb moves. Constrain the range with min, max, and step, add a label, and pass formatValue to render the displayed number (e.g. as a percentage or currency). The thumb is keyboard-adjustable with the arrow keys.

Example

Preview
20 – 80
import { Slider } from '@officina/ui';
import { useState } from 'react';

function VolumeSlider() {
  const [value, setValue] = useState([40]);
  return (
    <Slider
      label="Volume"
      value={value}
      onValueChange={setValue}
      min={0}
      max={100}
      step={5}
      formatValue={(n) => `${n}%`}
    />
  );
}

API

PropTypeDefaultDescription
onValueChange*(value: number[]) => void—Called with the updated value array as thumbs move.
value*number[]—Current thumb value(s). One entry per thumb.
disabledboolean—
formatValue(n: number) => string—Format a raw value for display (e.g. add a "$").
invalidboolean—Marks the field invalid for validation styling and `aria-invalid`.
labelstring—Visible label above the track.
maxnumber100Maximum value. Defaults to 100.
minnumber0Minimum value. Defaults to 0.
namestring—Form field name, for native form submission / form libraries.
stepnumber1Step increment. Defaults to 1.

On this page