> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt.

# Slider

Data Entry`@rockshin/tao-ui`

[Examples](#examples)[API](#api)

Selects a numeric value or range using pointer and keyboard input.

## When to use

Use when approximate adjustment is more useful than typing. Show the current value and units next to the slider.

## Examples


### Controlled value and completion
onChange follows each movement; onChangeComplete reports the final pointer or keyboard interaction.
```tsx preview="iframe-follow"
import { useState } from 'react';
import { Slider, Stack } from '@rockshin/tao-ui';

export default function Example() {
  const [value, setValue] = useState(35);
  const [committed, setCommitted] = useState(35);
  return (
    <Stack gap="md">
      <span>Volume: {value}%</span>
      <Slider
        value={value}
        onChange={setValue}
        onChangeComplete={setCommitted}
        ariaLabelForHandle="Volume"
      />
      <output>Last completed value: {committed}%</output>
    </Stack>
  );
}
```

### Range and draggable track
Drag either handle to resize the range or drag the selected track to move both endpoints.
```tsx preview
import { useState } from 'react';
import { Slider, Stack } from '@rockshin/tao-ui';

export default function Example() {
  const [range, setRange] = useState([20, 60]);
  return (
    <Stack gap="md">
      <output>
        Budget: {range[0]}–{range[1]}
      </output>
      <Slider
        range={{ draggableTrack: true }}
        value={range}
        onChange={setRange}
        ariaLabelForHandle={['Minimum budget', 'Maximum budget']}
      />
    </Stack>
  );
}
```

### Marks and discrete values
step={null} restricts selection to marks. dots shows all valid step positions.
```tsx preview
import { Slider, Stack } from '@rockshin/tao-ui';

export default function Example() {
  return (
    <Stack gap="lg">
      <Slider
        defaultValue={25}
        step={null}
        marks={{ 0: 'Off', 25: 'Low', 50: 'Mid', 100: 'High' }}
        ariaLabelForHandle="Quality preset"
      />
      <Slider
        defaultValue={40}
        step={20}
        dots
        marks={{ 0: '0', 100: '100' }}
        ariaLabelForHandle="Opacity"
      />
    </Stack>
  );
}
```

### Tooltip formatting
Set formatter to null to suppress the tooltip, or open to keep it visible.
```tsx preview
import { Slider, Stack } from '@rockshin/tao-ui';

export default function Example() {
  return (
    <Stack gap="lg" style={{ paddingBlock: 24 }}>
      <Slider
        defaultValue={42}
        tooltip={{ formatter: (value) => `${value} °C`, open: true }}
        ariaLabelForHandle="Temperature"
      />
      <Slider
        defaultValue={60}
        tooltip={{ formatter: null }}
        ariaLabelForHandle="Tooltip-free value"
      />
    </Stack>
  );
}
```

### Vertical, reversed and RTL
A vertical slider needs an explicit container height. direction controls keyboard and horizontal value direction.
```tsx preview
import { Slider, Stack } from '@rockshin/tao-ui';

export default function Example() {
  return (
    <Stack gap="lg">
      <div style={{ height: 150, paddingInline: 20 }}>
        <Slider
          orientation="vertical"
          defaultValue={40}
          marks={{ 0: '0', 100: '100' }}
          ariaLabelForHandle="Vertical value"
        />
      </div>
      <Slider reverse defaultValue={30} ariaLabelForHandle="Reversed value" />
      <Slider
        direction="rtl"
        defaultValue={60}
        ariaLabelForHandle="RTL value"
      />
    </Stack>
  );
}
```

### Editable ranges
Click the rail to add a handle. Drag a handle away from the rail to remove it, within minCount and maxCount.
```tsx preview
import { useState } from 'react';
import { Slider, Stack } from '@rockshin/tao-ui';

export default function Example() {
  const [values, setValues] = useState([20, 50, 80]);
  return (
    <Stack gap="md">
      <Slider
        range={{ editable: true, minCount: 2, maxCount: 5 }}
        value={values}
        onChange={setValues}
      />
      <output>Stops: {values.join(', ')}</output>
    </Stack>
  );
}
```

### Disabled state and focus
The ref exposes focus and blur. Semantic styles customize the track and handles.
```tsx preview
import { useRef } from 'react';
import { Button, Slider, Stack } from '@rockshin/tao-ui';
import type { SliderRef } from '@rockshin/tao-ui';

export default function Example() {
  const ref = useRef<SliderRef>(null);
  return (
    <Stack gap="md">
      <Button variant="secondary" onClick={() => ref.current?.focus()}>
        Focus slider
      </Button>
      <Slider
        ref={ref}
        defaultValue={45}
        styles={{
          track: { background: '#14b8a6' },
          handle: { borderColor: '#14b8a6' },
        }}
        ariaLabelForHandle="Custom slider"
      />
      <Slider disabled defaultValue={45} ariaLabelForHandle="Disabled slider" />
    </Stack>
  );
}
```

## API


### [#](#slider)Slider



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |

