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
  3809548d_b98f_4c81_02f1_a87c1e2e9a81["button-group.tsx"]
  25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"]
  3809548d_b98f_4c81_02f1_a87c1e2e9a81 --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df
  9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"]
  3809548d_b98f_4c81_02f1_a87c1e2e9a81 --> 9c463da6_747b_38dc_586b_cbb4873070b1
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  3809548d_b98f_4c81_02f1_a87c1e2e9a81 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  b2c60dee_4ede_8485_a6b4_91c999cdc69f["separator"]
  3809548d_b98f_4c81_02f1_a87c1e2e9a81 --> b2c60dee_4ede_8485_a6b4_91c999cdc69f
  style 3809548d_b98f_4c81_02f1_a87c1e2e9a81 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 "@/lib/utils"
import { Separator } from "@/registry/new-york-v4/ui/separator"

const buttonGroupVariants = cva(
  "flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
  {
    variants: {
      orientation: {
        horizontal:
          "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
        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(
        "bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
        className
      )}
      {...props}
    />
  )
}

function ButtonGroupSeparator({
  className,
  orientation = "vertical",
  ...props
}: React.ComponentProps<typeof Separator>) {
  return (
    <Separator
      data-slot="button-group-separator"
      orientation={orientation}
      className={cn(
        "bg-input relative !m-0 self-stretch data-[orientation=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/new-york-v4/ui/button-group.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: apps/v4/registry/new-york-v4/ui).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free