Range slider example

Default values and form reset.

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

Complete React client module · MIT · Next.js and Vite

Interactive example

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>;
}