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
  58d3ca56_5329_e101_4192_16d96565243a["Switch()"]
  0bb9b01b_fb14_dfa7_83b0_4964ae04fee0["switch.tsx"]
  58d3ca56_5329_e101_4192_16d96565243a -->|defined in| 0bb9b01b_fb14_dfa7_83b0_4964ae04fee0
  style 58d3ca56_5329_e101_4192_16d96565243a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/bases/radix/ui/switch.tsx lines 8–31

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(
        "cn-switch peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50",
        className
      )}
      {...props}
    >
      <SwitchPrimitive.Thumb
        data-slot="switch-thumb"
        className="cn-switch-thumb pointer-events-none block ring-0 transition-transform"
      />
    </SwitchPrimitive.Root>
  )
}

Subdomains

Frequently Asked Questions

What does Switch() do?
Switch() is a function in the ui codebase, defined in apps/v4/registry/bases/radix/ui/switch.tsx.
Where is Switch() defined?
Switch() is defined in apps/v4/registry/bases/radix/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