Slider

An input component for selecting a value or range of values along a track.

Overview

The Slider component provides an accessible way for users to select a value or range of values along a continuous or discrete scale. Built on Base UI primitives, it offers full keyboard navigation, touch support, and optional tooltip displays.

Usage

import { Slider, SliderThumb } from "@tilt-legal/cubitt-components/primitives";
<Slider defaultValue={[50]} max={100} step={1}>
  <SliderThumb />
</Slider>

Examples

Default

Range Slider

Use two thumbs to select a range of values.

With Labels

Add labels to indicate the range or meaning of values.

With Tooltip

Show the current value in a tooltip while dragging.

With Ticks

Display tick marks to indicate discrete values or steps.

Price Range with Inputs

Combine sliders with number inputs for precise control.

Rating Slider

Create custom rating interfaces with emoji indicators.

Climate Control

Complex example with multiple sliders and reset functionality.

Vertical Slider

Sliders can be oriented vertically for space-constrained layouts.

Disabled

URL State

Sync the slider with the URL using paramName.

API Reference

Slider

The root slider component with track and range indicator.

PropTypeDefaultDescription
defaultValuenumber[]The default value when uncontrolled.
valuenumber[]The controlled value of the slider.
onValueChange(value: number | number[]) => voidCallback fired when the value changes.
minnumber0The minimum value of the slider.
maxnumber100The maximum value of the slider.
stepnumber1The stepping interval.
orientation"horizontal" | "vertical""horizontal"The orientation of the slider.
disabledbooleanfalseWhether the slider is disabled.
showTooltipbooleanfalseShow tooltip with value while dragging.
tooltipContent(value: number) => React.ReactNodeCustom content for the tooltip.
tooltipVariant"default" | "light""default"The visual variant of the tooltip.
namestringThe name for form submission.
classNamestringAdditional CSS classes for the slider.

URL State Props

When provided with a paramName, the slider will sync its value with URL parameters via TanStack Router search params. The URL updates only when you release the thumb, not while dragging.

PropTypeDefaultDescription
paramNamestringURL parameter name for syncing state with URL. Enables URL state management.
onUrlValueChange(value: number[]) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleantrueRemove URL param when value equals default.
paramThrottlenumberThrottle URL updates in milliseconds.
paramDebouncenumberDebounce URL updates in milliseconds.

SliderThumb

The draggable thumb control for the slider.

PropTypeDescription
classNamestringAdditional CSS classes for the thumb.

On this page