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 144ec659_fe66_180d_5a2b_6b4728d590b3["toggle-group.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 144ec659_fe66_180d_5a2b_6b4728d590b3 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 191e4a89_25e4_f7a3_d5fb_d71d101e0990["utils"] 144ec659_fe66_180d_5a2b_6b4728d590b3 --> 191e4a89_25e4_f7a3_d5fb_d71d101e0990 61901fff_e0e9_9e5b_700d_48033d37776d["toggle"] 144ec659_fe66_180d_5a2b_6b4728d590b3 --> 61901fff_e0e9_9e5b_700d_48033d37776d 25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"] 144ec659_fe66_180d_5a2b_6b4728d590b3 --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df 9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"] 144ec659_fe66_180d_5a2b_6b4728d590b3 --> 9c463da6_747b_38dc_586b_cbb4873070b1 style 144ec659_fe66_180d_5a2b_6b4728d590b3 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 { toggleVariants } from "@/examples/radix/ui/toggle"
import { type VariantProps } from "class-variance-authority"
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
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(
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-vertical:flex-col data-vertical:items-stretch data-[size=sm]:rounded-[min(var(--radius-md),10px)]",
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(
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg 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 DocumentationAtlas domain, Changelog 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/examples/radix/ui/toggle-group.tsx (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/examples/radix/ui).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free