Skip to content

Slider

A value picked by dragging along a track, with its formatted value beside the label. Two values make a range whose thumbs never cross.

Language
Appearance

One value

1
import { useState } from 'react';
import { Slider } from '@arbol-ai/ui';

const SpeedExample = () => {
  const [speed, setSpeed] = useState(1);
  return (
    <Slider
      className="max-w-sm"
      label="Speaking speed"
      maxValue={1.2}
      minValue={0.7}
      onChange={setSpeed}
      step={0.05}
      value={speed}
    />
  );
};

<SpeedExample />

A range

COP 60,000 – COP 180,000
import { Slider } from '@arbol-ai/ui';

<Slider
  className="max-w-sm"
  defaultValue={[60_000, 180_000]}
  formatOptions={{ currency: 'COP', maximumFractionDigits: 0, style: 'currency' }}
  label="Consultation price"
  maxValue={300_000}
  step={10_000}
/>

Without a visible label

import { Slider } from '@arbol-ai/ui';

<div className="flex max-w-sm items-center gap-3 text-sm">
  <span aria-hidden>A</span>
  <Slider aria-label="Text size" defaultValue={16} maxValue={24} minValue={12} />
  <span aria-hidden className="text-lg">
    A
  </span>
</div>

Source

The examples above are src/components/slider/slider.examples.tsx, which the library’s tests render too.

Type to search…

↑↓ navigate↵ selectEsc close