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 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de["toggle-group.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 191e4a89_25e4_f7a3_d5fb_d71d101e0990["utils"] 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de --> 191e4a89_25e4_f7a3_d5fb_d71d101e0990 8c3a4304_fadd_0dcb_22c1_a0e81cf020d3["toggle"] 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de --> 8c3a4304_fadd_0dcb_22c1_a0e81cf020d3 25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"] 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df 9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"] 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de --> 9c463da6_747b_38dc_586b_cbb4873070b1 style 07a38fc1_0da5_c7b4_6a53_c2f0a2fbc5de 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-rtl/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-s-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-e-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-s-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-s 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, SearchAPI 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-rtl/toggle-group.tsx (domain: DocumentationAtlas, subdomain: SearchAPI, 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