Forms

Range slider.

Two clear bounds with precise steps and a defined minimum gap.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/range-slider.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

An ordered range

Two labelled thumbs retain a minimum gap and report live and committed values.

Keyboard

  • Tab reaches each thumb in order.
  • Arrow keys adjust by five; Home/End respect the minimum gap.

States covered

  • Two values
  • Clamped collision
  • Committed feedback

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-range-budget.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {RangeSlider} from '@bld8/ui';
export default function BudgetExample(){
  const [budget,setBudget]=useState<[number,number]>([20,80]),[committed,setCommitted]=useState('');
  return <div><RangeSlider label="Monthly budget" name="budget" value={budget} onValueChange={setBudget}
    onValueCommitted={range=>setCommitted(range.join(' to '))} min={0} max={100} step={5} minGap={10}
    thumbLabels={['Minimum budget','Maximum budget']} hint="Keep at least 10 between the lower and upper values."/>
    <p role="status">{committed?'Committed '+committed:'Adjust either end of the range.'}</p>
  </div>;
}

Default values and form reset

Both named thumbs submit values; reset restores the initial range.

Keyboard

  • Tab reaches both labelled thumbs.
  • Reset restores the initial values without firing a user edit.

States covered

  • Uncontrolled
  • Reset
  • Disabled range

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-range-uncontrolled.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {Button,RangeSlider} from '@bld8/ui';
export default function RetentionExample(){
  const [status,setStatus]=useState('');
  return <form onSubmit={event=>{event.preventDefault();setStatus('Retention values: '+new FormData(event.currentTarget).getAll('retention').join(', '));}}>
    <RangeSlider label="Retention window" name="retention" defaultValue={[15,45]} min={0} max={60} step={5} minGap={10}
      thumbLabels={['Earliest retention','Latest retention']} hint="Keep a minimum interval of ten."/>
    <RangeSlider label="Locked example range" defaultValue={[20,40]} disabled/>
    <Button type="submit">Read retention values</Button><Button type="reset" variant="secondary">Reset retention example</Button>
    <p role="status">{status}</p>
  </form>;
}

Quick reference

React / TypeScript
<RangeSlider label="Budget" value={budget} onValueChange={setBudget}
  min={0} max={1000} step={25} minGap={100} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

A controlled or uncontrolled numeric pair. Two labelled native range inputs support keyboard and form submission. minGap is expressed in value units and rounded up to whole steps. Clamp is the default collision rule; push optionally moves the other thumb during pointer interaction. Values stay ordered. onValueCommitted reports completed interactions. Disabled, hint/error, refs and native form reset are supported; currency and business validation belong to the host.

RangeSlider

RangeSlider public properties
PropTypeDefault
labelRequiredstring—
classNamestring | undefined—
crossing"clamp" | "push" | undefined

Pointer collision: clamp stops the thumb; push moves its neighbour. Keyboard always preserves order and minGap.

'clamp'
defaultValuereadonly [number, number] | undefined—
disabledboolean | undefined—
errorstring | undefined—
formstring | undefined—
hintstring | undefined—
idstring | undefined—
inputRefsreadonly [Ref<HTMLInputElement> | undefined, Ref<HTMLInputElement> | undefined] | undefined—
maxnumber | undefined100
minnumber | undefined0
minGapnumber | undefined

Minimum distance in value units, rounded up to a whole number of steps.

0
namestring | undefined—
onBlurFocusEventHandler<HTMLInputElement> | undefined—
onValueChange((value: RangeSliderValue) => void) | undefined—
onValueCommitted((value: RangeSliderValue) => void) | undefined—
stepnumber | undefined1
thumbLabelsreadonly [string, string] | undefined

Each thumb has its own accessible name. Defaults to Lower/Upper + label.

—
valuereadonly [number, number] | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.