"use client" /** * Slider — Radix-backed range input with token-aligned track + thumb * styling. * * Use for **continuous numeric ranges** with a clear visual track: brand * brightness, threshold sliders, audio scrubbing, density / scale * pickers. For discrete enumerable values (3 sizes, low / med / high), * prefer `ToggleGroup` or `RadioGroup` instead — sliders imply continuity. * * Pass `value` / `defaultValue` as `number[]` for either a single thumb * (`[value]`) or a range (`[min, max]`). Two thumbs share a track. * * Accessibility (per Radix): * - Each thumb is a focusable `role="slider"` with proper ARIA value * text. Pair with a visible label / `aria-label` when there is no * surrounding form field. * - Arrow keys nudge by `step`; Page Up / Down nudge by 10×; Home / End * jump to bounds. */ import * as React from "react" import { Slider as SliderPrimitive } from "radix-ui" import { cn } from "../../lib/utils" function Slider({ className, defaultValue, value, min = 0, max = 100, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: React.ComponentProps) { // `_values` drives how many `Thumb` elements we render so the same // component handles both single-thumb and dual-thumb ranges without // a separate prop. Falls back to `[min, max]` if nothing was supplied // (Radix accepts this — the slider just sits at the full range). const _values = React.useMemo( () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max], [value, defaultValue, min, max], ) return ( {_values.map((_, index) => ( ))} ) } export { Slider }