Home / File/ button-group.tsx — ui Source File

button-group.tsx — ui Source File

Architecture documentation for button-group.tsx, a tsx file in the ui codebase. 4 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 4 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  90d2b58e_e0c7_1859_1a6b_16d6713f1246["button-group.tsx"]
  25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"]
  90d2b58e_e0c7_1859_1a6b_16d6713f1246 --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df
  9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"]
  90d2b58e_e0c7_1859_1a6b_16d6713f1246 --> 9c463da6_747b_38dc_586b_cbb4873070b1
  ef4051f4_aeb7_8d0c_a726_0ba96ad80cf6["utils"]
  90d2b58e_e0c7_1859_1a6b_16d6713f1246 --> ef4051f4_aeb7_8d0c_a726_0ba96ad80cf6
  ce9c943c_1595_a786_2c59_160dbbb2ba0f["separator"]
  90d2b58e_e0c7_1859_1a6b_16d6713f1246 --> ce9c943c_1595_a786_2c59_160dbbb2ba0f
  style 90d2b58e_e0c7_1859_1a6b_16d6713f1246 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"

import { cn } from "@/registry/bases/radix/lib/utils"
import { Separator } from "@/registry/bases/radix/ui/separator"

const buttonGroupVariants = cva(
  "cn-button-group flex w-fit items-stretch *:focus-visible:z-10 *:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 ",
  {
    variants: {
      orientation: {
        horizontal:
          "cn-button-group-orientation-horizontal [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
        vertical:
          "cn-button-group-orientation-vertical flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
      },
    },
    defaultVariants: {
      orientation: "horizontal",
    },
  }
)

function ButtonGroup({
  className,
  orientation,
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
  return (
    <div
      role="group"
      data-slot="button-group"
      data-orientation={orientation}
      className={cn(buttonGroupVariants({ orientation }), className)}
      {...props}
    />
  )
}

function ButtonGroupText({
  className,
  asChild = false,
  ...props
}: React.ComponentProps<"div"> & {
  asChild?: boolean
}) {
  const Comp = asChild ? Slot.Root : "div"

  return (
    <Comp
      className={cn(
        "cn-button-group-text flex items-center [&_svg]:pointer-events-none",
        className
      )}
      {...props}
    />
  )
}

function ButtonGroupSeparator({
  className,
  orientation = "vertical",
  ...props
}: React.ComponentProps<typeof Separator>) {
  return (
    <Separator
      data-slot="button-group-separator"
      orientation={orientation}
      className={cn(
        "cn-button-group-separator relative self-stretch data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",
        className
      )}
      {...props}
    />
  )
}

export {
  ButtonGroup,
  ButtonGroupSeparator,
  ButtonGroupText,
  buttonGroupVariants,
}

Subdomains

Dependencies

  • class-variance-authority
  • radix-ui
  • separator
  • utils

Frequently Asked Questions

What does button-group.tsx do?
button-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 button-group.tsx?
button-group.tsx defines 3 function(s): ButtonGroup, ButtonGroupSeparator, ButtonGroupText.
What does button-group.tsx depend on?
button-group.tsx imports 4 module(s): class-variance-authority, radix-ui, separator, utils.
Where is button-group.tsx in the architecture?
button-group.tsx is located at apps/v4/registry/bases/radix/ui/button-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