Home / File/ switch.tsx — ui Source File

switch.tsx — ui Source File

Architecture documentation for switch.tsx, a tsx file in the ui codebase. 2 imports, 0 dependents.

File tsx DocumentationAtlas Changelog 2 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  5a9d1a7c_7900_8a6a_16da_eb0825b4e175["switch.tsx"]
  3d9438e8_7604_787c_4898_907262aff28b["utils"]
  5a9d1a7c_7900_8a6a_16da_eb0825b4e175 --> 3d9438e8_7604_787c_4898_907262aff28b
  1f3630eb_9348_92e5_a98d_b3202f89783c["switch"]
  5a9d1a7c_7900_8a6a_16da_eb0825b4e175 --> 1f3630eb_9348_92e5_a98d_b3202f89783c
  style 5a9d1a7c_7900_8a6a_16da_eb0825b4e175 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import { cn } from "@/examples/base/lib/utils"
import { Switch as SwitchPrimitive } from "@base-ui/react/switch"

function Switch({
  className,
  size = "default",
  ...props
}: SwitchPrimitive.Root.Props & {
  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"
      />
    </SwitchPrimitive.Root>
  )
}

export { Switch }

Subdomains

Functions

Dependencies

  • switch
  • utils

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, Changelog subdomain.
What functions are defined in switch.tsx?
switch.tsx defines 1 function(s): Switch.
What does switch.tsx depend on?
switch.tsx imports 2 module(s): switch, utils.
Where is switch.tsx in the architecture?
switch.tsx is located at apps/v4/examples/base/ui/switch.tsx (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/examples/base/ui).

Analyze Your Own Codebase

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

Try Supermodel Free