Slider

A control that lets users select a numeric value from a range by dragging a thumb along a track.

Examples

Basic

50

Sizes

30
50
70

Custom format

72°F

Steps

50%

Range

$25 — $75

Disabled

40

Custom composition

60%

Controlled

50

Overview

Slider lets users pick a numeric value within a range. It supports labels, live readout, custom formatting, range selection (two thumbs), and three sizes. Built on Base UI Slider.

tsx
import { Slider } from "@rogo-technologies/ui/slider";

<Slider defaultValue={50} label="Volume" showValue />;

Usage

Sizes

SizeTrack heightThumbUse case
sm4px14pxCompact controls, settings panels
md6px16pxDefault — forms, dialogs
lg8px20pxProminent controls, hero sections
tsx
<Slider defaultValue={30} size="sm" label="Small" showValue />
<Slider defaultValue={70} size="lg" label="Large" showValue />

Custom format

tsx
<Slider defaultValue={72} label="Temperature" showValue formatValue={(v) => `${v}°F`} />

Steps

Snap the thumb to discrete increments.

tsx
<Slider defaultValue={50} step={10} label="Opacity" showValue formatValue={(v) => `${v}%`} />

Range

Pass an array to defaultValue and render two SliderThumbs. Use the sub-components for full control.

tsx
import {
  SliderRoot,
  SliderControl,
  SliderTrack,
  SliderIndicator,
  SliderThumb,
  SliderLabel,
  SliderValue,
} from "@rogo-technologies/ui/slider";

<SliderRoot defaultValue={[25, 75]}>
  <div className="flex items-end justify-between">
    <SliderLabel size="md">Price range</SliderLabel>
    <SliderValue size="md">{(_formatted, values) => `$${values[0]} — $${values[1]}`}</SliderValue>
  </div>
  <SliderControl>
    <SliderTrack size="md">
      <SliderIndicator size="md" />
      <SliderThumb size="md" index={0} aria-label="Minimum price" />
      <SliderThumb size="md" index={1} aria-label="Maximum price" />
    </SliderTrack>
  </SliderControl>
</SliderRoot>;

Custom composition

Sub-components accept their own className so you can override track color, indicator style, or thumb appearance.

tsx
<SliderRoot defaultValue={60} min={0} max={100}>
  <div className="flex items-end justify-between">
    <SliderLabel size="md">Custom composition</SliderLabel>
    <SliderValue size="md">{(_formatted, values) => `${values[0]}%`}</SliderValue>
  </div>
  <SliderControl>
    <SliderTrack size="lg" className="bg-quaternary">
      <SliderIndicator size="lg" className="bg-brand-inverted" />
      <SliderThumb size="lg" />
    </SliderTrack>
  </SliderControl>
</SliderRoot>

Controlled

tsx
const [value, setValue] = useState(50);

<Slider value={value} onValueChange={(v) => setValue(v)} label="Volume" showValue />;

API

Slider (composed)

PropTypeDefaultDescription
valuenumber | number[]Controlled value.
defaultValuenumber | number[]Uncontrolled initial value.
onValueChange(value: number | number[]) => voidCalled during value changes.
onValueCommitted(value: number | number[]) => voidCalled on pointer up.
minnumber0Minimum allowed value.
maxnumber100Maximum allowed value.
stepnumber1Step increment.
disabledbooleanfalseDisables the slider.
orientation"horizontal" | "vertical""horizontal"Layout direction.
size"sm" | "md" | "lg""md"Size of the slider.
labelstringLabel text displayed above the track.
showValuebooleanfalseWhether to show the value readout.
formatValue(value: number) => stringCustom value formatter.
classNamestringAdditional CSS classes for the root.
trackClassNamestringAdditional CSS classes for the track.
indicatorClassNamestringAdditional CSS classes for the indicator.
thumbClassNamestringAdditional CSS classes for the thumb.

Sub-components

ComponentDescription
SliderRootRoot container. Accepts all Slider.Root props + size.
SliderControlDraggable interaction area.
SliderTrackThe visible track. Accepts size.
SliderIndicatorThe filled range portion. Accepts size.
SliderThumbThe draggable handle. Accepts size and index (for range).
SliderValueDisplays the current value. Accepts size and children render function.
SliderLabelLabel element. Accepts size.

Guidelines

Do

  • Provide a label or aria-label for accessibility
  • Use showValue when the exact number matters to the user
  • Use formatValue to add units (%, px, °F, etc.)
  • Use step for values that should snap to discrete increments
  • Use range sliders for min/max filters (e.g., price range)

Don't

  • Don't use a slider when only a few discrete values exist — use radio buttons or a select instead
  • Don't hide the value when precision matters — show it with showValue
  • Don't use a slider for text input or non-numeric values
  • Don't set min and max too close together — the control becomes imprecise
PreviousShimmer
NextSwitch
Made in NYC© 2026 Rogo Technologies Inc.