MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / Switch

Function Switch

apps/ui/src/components/ui/switch.tsx:9–34  ·  view source on GitHub ↗
({
  className,
  size = "default",
  ...props
}: React.ComponentProps<typeof SwitchPrimitive.Root> & {
  size?: "sm" | "default";
})

Source from the content-addressed store, hash-verified

7import { cn } from "@/lib/classnames";
8
9function Switch({
10 className,
11 size = "default",
12 ...props
13}: React.ComponentProps<typeof SwitchPrimitive.Root> & {
14 size?: "sm" | "default";
15}) {
16 return (
17 <SwitchPrimitive.Root
18 data-slot='switch'
19 data-size={size}
20 className={cn(
21 "peer group/switch focus-visible:ring-primary/40 data-[state=checked]:bg-primary data-[state=checked]:border-primary-strong/50 data-[state=unchecked]:bg-panel-strong data-[state=unchecked]:border-border-strong/40 inline-flex shrink-0 items-center rounded-full border transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6",
22 className
23 )}
24 {...props}
25 >
26 <SwitchPrimitive.Thumb
27 data-slot='switch-thumb'
28 className={cn(
29 "data-[state=checked]:bg-primary-ink data-[state=unchecked]:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
30 )}
31 />
32 </SwitchPrimitive.Root>
33 );
34}
35
36export { Switch };

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected