import { useEffect, useState } from 'react' import { Slider as SliderPrimitive } from '@base-ui/react/slider' import { cn } from './utils' type SliderProps = SliderPrimitive.Root.Props & { /** Animate movement between discrete values, including while dragging. */ animate?: boolean } function Slider({ animate = false, children, className, defaultValue, value, min = 0, max = 100, ...props }: SliderProps) { const [animationReady, setAnimationReady] = useState(false) const _values = Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min] // Let Base UI measure the initial positions before transitions are enabled. useEffect(() => { const frame = requestAnimationFrame(() => setAnimationReady(true)) return () => cancelAnimationFrame(frame) }, []) return ( {children} {Array.from({ length: _values.length }, (_, index) => ( ))} ) } export { Slider }