MCPcopy Create free account
hub / github.com/arctic-cli/interface / Slider

Function Slider

packages/web/components/ui/slider.tsx:8–64  ·  view source on GitHub ↗
({
  className,
  children,
  defaultValue,
  value,
  min = 0,
  max = 100,
  ...props
}: SliderPrimitive.Root.Props)

Source from the content-addressed store, hash-verified

6import { cn } from "@/lib/utils";
7
8function Slider({
9 className,
10 children,
11 defaultValue,
12 value,
13 min = 0,
14 max = 100,
15 ...props
16}: SliderPrimitive.Root.Props) {
17 const _values = React.useMemo(() => {
18 if (value !== undefined) {
19 return Array.isArray(value) ? value : [value];
20 }
21 if (defaultValue !== undefined) {
22 return Array.isArray(defaultValue) ? defaultValue : [defaultValue];
23 }
24 return [min];
25 }, [value, defaultValue, min]);
26
27 return (
28 <SliderPrimitive.Root
29 className="data-[orientation=horizontal]:w-full"
30 defaultValue={defaultValue}
31 max={max}
32 min={min}
33 thumbAlignment="edge"
34 value={value}
35 {...props}
36 >
37 {children}
38 <SliderPrimitive.Control
39 className={cn(
40 "flex touch-none select-none data-disabled:pointer-events-none data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=horizontal]:w-full data-[orientation=horizontal]:min-w-44 data-[orientation=vertical]:flex-col data-disabled:opacity-64",
41 className,
42 )}
43 data-slot="slider-control"
44 >
45 <SliderPrimitive.Track
46 className="relative grow select-none before:absolute before:rounded-full before:bg-input data-[orientation=horizontal]:h-1 data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-1 data-[orientation=horizontal]:before:inset-x-0.5 data-[orientation=vertical]:before:inset-x-0 data-[orientation=horizontal]:before:inset-y-0 data-[orientation=vertical]:before:inset-y-0.5"
47 data-slot="slider-track"
48 >
49 <SliderPrimitive.Indicator
50 className="select-none rounded-full bg-primary data-[orientation=horizontal]:ms-0.5 data-[orientation=vertical]:mb-0.5"
51 data-slot="slider-indicator"
52 />
53 {Array.from({ length: _values.length }, (_, index) => (
54 <SliderPrimitive.Thumb
55 className="block size-5 shrink-0 select-none rounded-full border border-input bg-white bg-clip-padding shadow-xs outline-none transition-shadow before:absolute before:inset-0 before:rounded-full before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-[3px] focus-visible:ring-ring/24 has-focus-visible:ring-[3px] has-focus-visible:ring-ring/24 data-dragging:ring-[3px] data-dragging:ring-ring/24 sm:size-4 dark:border-background dark:bg-clip-border dark:data-dragging:ring-ring/48 dark:focus-visible:ring-ring/48 [:focus-visible,[data-dragging]]:shadow-none"
56 data-slot="slider-thumb"
57 key={String(index)}
58 />
59 ))}
60 </SliderPrimitive.Track>
61 </SliderPrimitive.Control>
62 </SliderPrimitive.Root>
63 );
64}
65

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected