toggle-group.tsx — ui Source File
Architecture documentation for toggle-group.tsx, a tsx file in the ui codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d735d975_8950_adbf_6ccd_72065edcb10d["toggle-group.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] d735d975_8950_adbf_6ccd_72065edcb10d --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 8014e1e4_19c1_40dc_68ec_b28df439b8ed["toggle"] d735d975_8950_adbf_6ccd_72065edcb10d --> 8014e1e4_19c1_40dc_68ec_b28df439b8ed 29d61405_7856_0804_8e40_eb1b6fa3c8b5["toggle-group"] d735d975_8950_adbf_6ccd_72065edcb10d --> 29d61405_7856_0804_8e40_eb1b6fa3c8b5 25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"] d735d975_8950_adbf_6ccd_72065edcb10d --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df 8ad666ec_1b20_adda_0392_87a60bdb3a68["utils"] d735d975_8950_adbf_6ccd_72065edcb10d --> 8ad666ec_1b20_adda_0392_87a60bdb3a68 5a1264c3_a99d_8bb7_b4f2_3070fbb69d0c["toggle"] d735d975_8950_adbf_6ccd_72065edcb10d --> 5a1264c3_a99d_8bb7_b4f2_3070fbb69d0c style d735d975_8950_adbf_6ccd_72065edcb10d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group"
import { type VariantProps } from "class-variance-authority"
import { cn } from "@/registry/bases/base/lib/utils"
import { toggleVariants } from "@/registry/bases/base/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
}: ToggleGroupPrimitive.Props &
VariantProps<typeof toggleVariants> & {
spacing?: number
orientation?: "horizontal" | "vertical"
}) {
return (
<ToggleGroupPrimitive
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>
)
}
function ToggleGroupItem({
className,
children,
variant = "default",
size = "default",
...props
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
const context = React.useContext(ToggleGroupContext)
return (
<TogglePrimitive
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}
</TogglePrimitive>
)
}
export { ToggleGroup, ToggleGroupItem }
Domain
Subdomains
Functions
Dependencies
- class-variance-authority
- react
- toggle
- toggle
- toggle-group
- 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, UIPrimitives 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 6 module(s): class-variance-authority, react, toggle, toggle, toggle-group, utils.
Where is toggle-group.tsx in the architecture?
toggle-group.tsx is located at apps/v4/registry/bases/base/ui/toggle-group.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: apps/v4/registry/bases/base/ui).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free