slider.tsx
1,038 bytes
| 1 | 'use client'; |
|---|---|
| 2 | |
| 3 | import * as SliderPrimitive from '@radix-ui/react-slider'; |
| 4 | import * as React from 'react'; |
| 5 | import { cn } from '@/lib/utils'; |
| 6 | |
| 7 | const Slider = React.forwardRef< |
| 8 | React.ElementRef<typeof SliderPrimitive.Root>, |
| 9 | React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> |
| 10 | >(({ className, ...props }, ref) => ( |
| 11 | <SliderPrimitive.Root |
| 12 | ref={ref} |
| 13 | className={cn('relative flex w-full touch-none select-none items-center', className)} |
| 14 | {...props} |
| 15 | > |
| 16 | <SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full bg-secondary"> |
| 17 | <SliderPrimitive.Range className="absolute h-full bg-primary" /> |
| 18 | </SliderPrimitive.Track> |
| 19 | <SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" /> |
| 20 | </SliderPrimitive.Root> |
| 21 | )); |
| 22 | Slider.displayName = SliderPrimitive.Root.displayName; |
| 23 | |
| 24 | export { Slider }; |
| 25 | |