Home / Function/ Switch() — ui Function Reference

Switch() — ui Function Reference

Architecture documentation for the Switch() function in switch.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  e8c8c558_6029_d193_94c4_0726679c4762["Switch()"]
  1955da35_530d_c73f_5930_901d9ff963e7["switch.tsx"]
  e8c8c558_6029_d193_94c4_0726679c4762 -->|defined in| 1955da35_530d_c73f_5930_901d9ff963e7
  style e8c8c558_6029_d193_94c4_0726679c4762 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/ui/switch.tsx lines 8–33

function Switch({
  className,
  size = "default",
  ...props
}: React.ComponentProps<typeof SwitchPrimitive.Root> & {
  size?: "sm" | "default"
}) {
  return (
    <SwitchPrimitive.Root
      data-slot="switch"
      data-size={size}
      className={cn(
        "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",
        className
      )}
      {...props}
    >
      <SwitchPrimitive.Thumb
        data-slot="switch-thumb"
        className={cn(
          "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"
        )}
      />
    </SwitchPrimitive.Root>
  )
}

Subdomains

Frequently Asked Questions

What does Switch() do?
Switch() is a function in the ui codebase, defined in apps/v4/registry/new-york-v4/ui/switch.tsx.
Where is Switch() defined?
Switch() is defined in apps/v4/registry/new-york-v4/ui/switch.tsx at line 8.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free