MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / Switch

Function Switch

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

Source from the content-addressed store, hash-verified

6import { cn } from "@/lib/utils"
7
8function Switch({
9 className,
10 size = "default",
11 ...props
12}: React.ComponentProps<typeof SwitchPrimitive.Root> & {
13 size?: "sm" | "default"
14}) {
15 return (
16 <SwitchPrimitive.Root
17 data-slot="switch"
18 data-size={size}
19 className={cn(
20 "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs 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",
21 className
22 )}
23 {...props}
24 >
25 <SwitchPrimitive.Thumb
26 data-slot="switch-thumb"
27 className={cn(
28 "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-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"
29 )}
30 />
31 </SwitchPrimitive.Root>
32 )
33}
34
35export { Switch }

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected