toggle-group.tsx — ui Source File
Architecture documentation for toggle-group.tsx, a tsx file in the ui codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 9d43e8e3_203c_eb9e_7615_34045fe17729["toggle-group.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 9d43e8e3_203c_eb9e_7615_34045fe17729 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"] 9d43e8e3_203c_eb9e_7615_34045fe17729 --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df 9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"] 9d43e8e3_203c_eb9e_7615_34045fe17729 --> 9c463da6_747b_38dc_586b_cbb4873070b1 ef4051f4_aeb7_8d0c_a726_0ba96ad80cf6["utils"] 9d43e8e3_203c_eb9e_7615_34045fe17729 --> ef4051f4_aeb7_8d0c_a726_0ba96ad80cf6 74da6c56_ce56_ff7d_d9b0_dd194fe8cf0b["toggle"] 9d43e8e3_203c_eb9e_7615_34045fe17729 --> 74da6c56_ce56_ff7d_d9b0_dd194fe8cf0b style 9d43e8e3_203c_eb9e_7615_34045fe17729 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import { type VariantProps } from "class-variance-authority"
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
import { cn } from "@/registry/bases/radix/lib/utils"
import { toggleVariants } from "@/registry/bases/radix/ui/toggle"
const ToggleGroupContext = React.createContext<
VariantProps<typeof toggleVariants> & {
spacing?: number
orientation?: "horizontal" | "vertical"
}
>({
size: "default",
variant: "default",
spacing: 0,
orientation: "horizontal",
})
function ToggleGroup({
className,
variant,
size,
spacing = 0,
orientation = "horizontal",
children,
...props
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
VariantProps<typeof toggleVariants> & {
spacing?: number
orientation?: "horizontal" | "vertical"
}) {
return (
<ToggleGroupPrimitive.Root
data-slot="toggle-group"
data-variant={variant}
data-size={size}
data-spacing={spacing}
data-orientation={orientation}
style={{ "--gap": spacing } as React.CSSProperties}
className={cn(
"cn-toggle-group group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-vertical:flex-col data-vertical:items-stretch",
className
)}
{...props}
>
<ToggleGroupContext.Provider
value={{ variant, size, spacing, orientation }}
>
{children}
</ToggleGroupContext.Provider>
</ToggleGroupPrimitive.Root>
)
}
function ToggleGroupItem({
className,
children,
variant = "default",
size = "default",
...props
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
VariantProps<typeof toggleVariants>) {
const context = React.useContext(ToggleGroupContext)
return (
<ToggleGroupPrimitive.Item
data-slot="toggle-group-item"
data-variant={context.variant || variant}
data-size={context.size || size}
data-spacing={context.spacing}
className={cn(
"cn-toggle-group-item shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
toggleVariants({
variant: context.variant || variant,
size: context.size || size,
}),
className
)}
{...props}
>
{children}
</ToggleGroupPrimitive.Item>
)
}
export { ToggleGroup, ToggleGroupItem }
Domain
Subdomains
Functions
Dependencies
- class-variance-authority
- radix-ui
- react
- toggle
- utils
Source
Frequently Asked Questions
What does toggle-group.tsx do?
toggle-group.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in toggle-group.tsx?
toggle-group.tsx defines 2 function(s): ToggleGroup, ToggleGroupItem.
What does toggle-group.tsx depend on?
toggle-group.tsx imports 5 module(s): class-variance-authority, radix-ui, react, toggle, utils.
Where is toggle-group.tsx in the architecture?
toggle-group.tsx is located at apps/v4/registry/bases/radix/ui/toggle-group.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: apps/v4/registry/bases/radix/ui).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free