Pho Design System

Slider

Picks a number — or a range — along a track by dragging. Built on Base UI Slider, with keyboard support and aria-valuenow. For a precise typed value, prefer NumberField.

Import

import { Slider } from "@photon-ai/pho-ui/components/slider";

Basic

Set defaultValue (or value), plus min / max / step on Slider.Root. Compose a header with Slider.Label + Slider.Value, then the track.

Volume
40
<Slider.Root defaultValue={40}>
  <div className="flex items-center justify-between">
    <Slider.Label>Volume</Slider.Label>
    <Slider.Value />
  </div>
  <Slider.Control>
    <Slider.Track>
      <Slider.Indicator />
      <Slider.Thumb />
    </Slider.Track>
  </Slider.Control>
</Slider.Root>

Range

Pass an array defaultValue and render one Slider.Thumb per value for a two-handle range.

Price range
25 – 75
<Slider.Root defaultValue={[25, 75]}>

  <Slider.Track>
    <Slider.Indicator />
    <Slider.Thumb />
    <Slider.Thumb />
  </Slider.Track>
</Slider.Root>

Steps and formatting

step snaps the value to fixed increments (here $50), and format takes Intl.NumberFormatOptions so Slider.Value reads out in the right units.

Monthly budget
$400
<Slider.Root
  defaultValue={400}
  min={0}
  max={1000}
  step={50}
  format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
>
  <div className="flex items-center justify-between">
    <Slider.Label>Monthly budget</Slider.Label>
    <Slider.Value />
  </div>

</Slider.Root>

Disabled

Set disabled on Slider.Root to freeze the value and drop the thumb out of the tab order.

Opacity
60
<Slider.Root defaultValue={60} disabled>

</Slider.Root>

Anatomy

Props

Slider.Root

Slider.Value

Slider.Thumb

Accessibility

Each Slider.Thumb renders a <div> around a native <input type="range"> with role="slider", aria-valuenow, aria-valuemin, aria-valuemax, and aria-orientation. Name the control with Slider.Label (associated for you), or aria-label / getAriaLabel(index) per thumb on a range. Use getAriaValueText when the raw number needs units or words to be understood (“$400”, not “400”).

Keyboard, with a thumb focused:

Each thumb’s input is individually tabbable and shows a ring on focus-visible; a disabled slider drops out of the tab order and dims to data-disabled. Slider.Value renders an <output> mirroring the live reading for sighted users, while the same number reaches assistive tech through aria-valuenow.

Best practices