Skip to main content

Range slider

Let people choose an approximate numeric value within a range using a range slider.

Examples

Breakpoints

Mobile

320px

Mobile Lg

480px

Tablet

640px

Desktop

1024px
range-slider-demo.tsx
import { RangeSlider } from '@uswds-tailwind/react'
export default function RangeSliderDemo() {
return (
<form className="max-w-xs">
<label htmlFor="range-value" className="block">Range slider</label>
<RangeSlider.Root name="range">
<RangeSlider.Input id="range-value" min={0} max={100} step={1} defaultValue={20} />
</RangeSlider.Root>
</form>
)
}

Component API

Use a Root and Input for a styled native range control.

Root<div>

Provides disabled state. For validation state, wrap the slider in Field.Root with invalid.

PropTypeDescription
disabledbooleanDisables the slider.
namestringForm field name.
AttributeValuePurpose
data-disabledPresent when disabledStyle the disabled state.

Input<input>

Native range input; set min, max, step, and value here.

AttributeValuePurpose
data-disabledPresent when disabledStyle the disabled state.
data-invalidPresent when invalidStyle the error state.