MCPcopy Create free account
hub / github.com/code-with-antonio/nodebase / Slider

Function Slider

src/components/ui/slider.tsx:8–61  ·  view source on GitHub ↗
({
  className,
  defaultValue,
  value,
  min = 0,
  max = 100,
  ...props
}: React.ComponentProps<typeof SliderPrimitive.Root>)

Source from the content-addressed store, hash-verified

6import { cn } from "@/lib/utils"
7
8function Slider({
9 className,
10 defaultValue,
11 value,
12 min = 0,
13 max = 100,
14 ...props
15}: React.ComponentProps<typeof SliderPrimitive.Root>) {
16 const _values = React.useMemo(
17 () =>
18 Array.isArray(value)
19 ? value
20 : Array.isArray(defaultValue)
21 ? defaultValue
22 : [min, max],
23 [value, defaultValue, min, max]
24 )
25
26 return (
27 <SliderPrimitive.Root
28 data-slot="slider"
29 defaultValue={defaultValue}
30 value={value}
31 min={min}
32 max={max}
33 className={cn(
34 "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
35 className
36 )}
37 {...props}
38 >
39 <SliderPrimitive.Track
40 data-slot="slider-track"
41 className={cn(
42 "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
43 )}
44 >
45 <SliderPrimitive.Range
46 data-slot="slider-range"
47 className={cn(
48 "bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
49 )}
50 />
51 </SliderPrimitive.Track>
52 {Array.from({ length: _values.length }, (_, index) => (
53 <SliderPrimitive.Thumb
54 data-slot="slider-thumb"
55 key={index}
56 className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
57 />
58 ))}
59 </SliderPrimitive.Root>
60 )
61}
62
63export { Slider }

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected