switch.tsx — ui Source File
Architecture documentation for switch.tsx, a tsx file in the ui codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8852bbf4_6246_90c6_d1d8_8c05d9ed114a["switch.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 8852bbf4_6246_90c6_d1d8_8c05d9ed114a --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 191e4a89_25e4_f7a3_d5fb_d71d101e0990["utils"] 8852bbf4_6246_90c6_d1d8_8c05d9ed114a --> 191e4a89_25e4_f7a3_d5fb_d71d101e0990 9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"] 8852bbf4_6246_90c6_d1d8_8c05d9ed114a --> 9c463da6_747b_38dc_586b_cbb4873070b1 style 8852bbf4_6246_90c6_d1d8_8c05d9ed114a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import { cn } from "@/examples/radix/lib/utils"
import { Switch as SwitchPrimitive } from "radix-ui"
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(
"data-checked:bg-primary data-unchecked:bg-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 aria-invalid:ring-3 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px]",
className
)}
{...props}
>
<SwitchPrimitive.Thumb
data-slot="switch-thumb"
className="bg-background dark:data-unchecked:bg-foreground dark:data-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 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 rtl:group-data-[size=default]/switch:data-checked:-translate-x-[calc(100%-2px)] rtl:group-data-[size=sm]/switch:data-checked:-translate-x-[calc(100%-2px)] rtl:group-data-[size=default]/switch:data-unchecked:-translate-x-0 rtl:group-data-[size=sm]/switch:data-unchecked:-translate-x-0"
/>
</SwitchPrimitive.Root>
)
}
export { Switch }
Domain
Subdomains
Functions
Dependencies
- radix-ui
- react
- utils
Source
Frequently Asked Questions
What does switch.tsx do?
switch.tsx is a source file in the ui codebase, written in tsx. It belongs to the DocumentationAtlas domain, ContentSourcing subdomain.
What functions are defined in switch.tsx?
switch.tsx defines 1 function(s): Switch.
What does switch.tsx depend on?
switch.tsx imports 3 module(s): radix-ui, react, utils.
Where is switch.tsx in the architecture?
switch.tsx is located at apps/v4/examples/radix/ui-rtl/switch.tsx (domain: DocumentationAtlas, subdomain: ContentSourcing, directory: apps/v4/examples/radix/ui-rtl).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free