Dual Range Slider Label Position
A demo component that renders two DualRangeSlider instances sharing one state value, one with labelPosition="top" and one with labelPosition="bottom", so the label placement can be compared side by side. It is a registry component that depends on the spectrumui dual range slider dependencies.
Installation
Requires @spectrumui in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import DualRangeSliderLabelPosition from "@/components/spectrumui/dual-range-slider-label-position";export default function Page() { return <DualRangeSliderLabelPosition />;}- Showing a comparison of where value labels sit relative to a dual range slider (above or below the track)
- Choosing between a top or bottom label placement for a range filter in a form or dashboard
- Reproducing the labelPosition option in a documentation or playground page
- Demonstrating a shared min/max range value bound to two sliders
Examples
Demo component as shipped
Renders the demo with both label positions stacked, sharing one range value.
import DualRangeSliderLabelPosition from "@/components/spectrumui/dual-range-slider-label-position";export default function Page() { return ( <main className="max-w-xl mx-auto py-12"> <DualRangeSliderLabelPosition /> </main> );}Top-positioned label with percentage formatting
Uses DualRangeSlider directly with labelPosition="top" and a label function that appends a percent sign.
import * as React from "react";import { useState } from "react";import { DualRangeSlider } from "@/components/ui/dual-range-slider";export default function TopLabelExample() { const [values, setValues] = useState([20, 80]); return ( <div className="w-full px-10"> <DualRangeSlider label={(value) => `${value}%`} labelPosition="top" value={values} onValueChange={setValues} min={0} max={100} step={5} /> </div> );}Bottom-positioned label for a price range
Uses labelPosition="bottom" with a currency-style label and a wider min/max range.
import * as React from "react";import { useState } from "react";import { DualRangeSlider } from "@/components/ui/dual-range-slider";export default function BottomLabelExample() { const [price, setPrice] = useState([1000, 5000]); return ( <div className="w-full px-10"> <DualRangeSlider label={(value) => `$${value}`} labelPosition="bottom" value={price} onValueChange={setPrice} min={0} max={10000} step={100} /> </div> );}API reference
Accessibility
- The slider inherits its keyboard and ARIA behavior from @/components/ui/dual-range-slider; verify the thumbs are operable with arrow keys after install.
- The "TOP:" and "BOTTOM:" captions are plain text and are not associated with the sliders; add aria-labelledby or a visible label element tied to each slider for screen reader users when reusing this pattern.
- The value labels rely on the label function's output, so keep them readable (sufficient contrast and text size) when using custom formatting.
- Labels positioned above or below the track should not overlap adjacent content; leave vertical space (the demo uses space-y-5 and mb-8).
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Dual Range Slider Label Position" component (spectrumui/dual-range-slider-label-position) from its shadcn registry.1. Install it with: npx shadcn@latest add @spectrumui/dual-range-slider-label-position2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: (demo component), label, labelPosition, value, onValueChange, min, max, step.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport DualRangeSliderLabelPosition from "@/components/spectrumui/dual-range-slider-label-position";export default function Page() { return <DualRangeSliderLabelPosition />;}```Files & dependencies
- app/registry/dual-range-slider/usage/dual-range-slider-label-position.tsx→ components/spectrumui/dual-range-slider-label-position.tsx
Looks similar, elsewhere
There is no screenshot of this item to compare yet.