MCPcopy Create free account
hub / github.com/MagicCube/agentara / Switch

Function Switch

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected