Component

Slider

Backed by @base-ui/react/slider. Anatomy is fixed: root, label, value, control, track, indicator, thumb parts. Base UI reference.

Install

npx bambiui add slider

Import from your own project source, never from Base UI directly, and never from a published bambiui package:

import { Slider } from "@/components/ui/slider";

Variants

horizontal
40
vertical
40

States

Default
30
Disabled
30

Hover, active, and focus-visible are styled but cannot be shown statically. Use the component with a mouse or keyboard to verify those interaction states.

Supported states: `default`, `hover`, `focus-visible`, `dragging`, `invalid`, `disabled`.

Props

PropTypeDefault
orientation"horizontal" | "vertical""horizontal"
labelReactNodeundefined
showValuebooleanfalse
getThumbAriaLabel(index: number) => stringundefined
valuenumber | number[]undefined
defaultValuenumber | number[]undefined
onValueChange(value: number | number[], details: Slider.Root.ChangeEventDetails) => voidundefined
onValueCommitted(value: number | number[], details: Slider.Root.CommitEventDetails) => voidundefined
minnumber0
maxnumber100
stepnumber1
largeStepnumber10
minStepsBetweenValuesnumber0
formatIntl.NumberFormatOptionsundefined
disabledbooleanfalse

Native props and refs supported by the underlying Base UI primitive are preserved.

Tokens

Override any of these in your theme CSS to restyle Slider:

  • --bambi-slider-track-size
  • --bambi-slider-thumb-size
  • --bambi-slider-control-padding
  • --bambi-slider-vertical-length
  • --bambi-slider-value-foreground
  • --bambi-track-background
  • --bambi-track-fill-background
  • --bambi-track-radius
  • --bambi-thumb-background
  • --bambi-thumb-border
  • --bambi-thumb-shadow
  • --bambi-label-foreground
  • --bambi-field-gap

Single and range

The thumb count follows the shape of the value: a number renders one thumb, and an array renders one per entry. Name each thumb with getThumbAriaLabel when there is more than one, since a single visible label cannot distinguish them.

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

<Slider
  defaultValue={[20, 70]}
  label="Price"
  showValue
  getThumbAriaLabel={(index) => (index === 0 ? "Minimum price" : "Maximum price")}
/>
Price
20 – 70

Value changes

onValueChange fires continuously while dragging; onValueCommitted fires once the interaction ends. Use the committed callback for anything expensive, such as a network request.

Layout

A horizontal slider fills its container. A vertical one falls back to --bambi-slider-vertical-length when its parent has no height, so set a height on the parent to control it. The pointer target is wider than the visible track, via --bambi-slider-control-padding.

Composition

Inside a Field, the slider picks up the field name, description, and disabled state:

Volume
65

Applies to notification sounds only.

Keyboard

Each thumb is its own tab stop and hosts a native range input.

KeyBehavior
/ / / Moves the focused thumb by step.
Page Up / Page DownMoves by largeStep. Shift with or does the same.
Home / EndJumps to min or max.

A disabled slider is removed from the tab order and ignores keyboard input.