Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Slider

An input where the user selects a value from within a given range.

Installation

npx logic2b@next add slider

Usage

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

<Slider aria-label="Volume" defaultValue={[50]} max={100} step={1} />

Usage notes

Built on Radix Slider.Root. Values are always arrays, so a single-thumb slider uses [value] and a range uses [start, end].

Examples

Range

Controlled

40

Vertical

Accessibility

  • Each thumb is a slider role element that is fully keyboard operable.
  • Arrow keys move by step; Page Up / Page Down move by a larger increment; Home / End jump to min / max.
  • Give the control a contextual aria-label, or point aria-labelledby at the id of a visible label, so screen readers announce its purpose.
  • For a range, use thumbLabels (for example ["Minimum price", "Maximum price"]) when the generated numbered names are not descriptive enough.
  • On range sliders each thumb is focusable independently and cannot cross past its neighbor.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<Slider
  defaultValue={[40]}
  min={0}
  max={100}
  aria-label="Volume"
 />

API reference

Generated from the public TypeScript exports in src/ui/slider.tsx.

View JSON

Slider

Component
Props: SliderProps
PropTypeRequiredDefaultDescription
minnumberNo0—
maxnumberNo100—
thumbLabelsstring[]No——
aria-labelstringNo"Slider value"—

Accessibility contract

Machine-readable behavior and consumer responsibilities for slider.

View JSON
Support
Primitive-managed
Pattern
slider
Radix Slider
Keyboard interactions for slider
KeysBehavior
ArrowUp ArrowDown ArrowLeft ArrowRightMove within the composite control.
Home End PageUp PageDownMove the focused thumb by the supported increment.

Built-in semantics

  • Each thumb exposes slider value/min/max semantics and supports range sliders.

Consumer responsibilities

  • Provide a contextual aria-label or aria-labelledby for every thumb.