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 DocumentationAtlas Changelog 4 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  1b68d921_4dee_79de_8c8e_b031f285cc34["button-group.tsx"]
  191e4a89_25e4_f7a3_d5fb_d71d101e0990["utils"]
  1b68d921_4dee_79de_8c8e_b031f285cc34 --> 191e4a89_25e4_f7a3_d5fb_d71d101e0990
  5f4cd78d_6790_583a_dafd_9fbe550c5cb6["separator"]
  1b68d921_4dee_79de_8c8e_b031f285cc34 --> 5f4cd78d_6790_583a_dafd_9fbe550c5cb6
  25383e8d_ca91_a50e_c3a8_5f228d02e1df["class-variance-authority"]
  1b68d921_4dee_79de_8c8e_b031f285cc34 --> 25383e8d_ca91_a50e_c3a8_5f228d02e1df
  9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"]
  1b68d921_4dee_79de_8c8e_b031f285cc34 --> 9c463da6_747b_38dc_586b_cbb4873070b1
  style 1b68d921_4dee_79de_8c8e_b031f285cc34 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { cn } from "@/examples/radix/lib/utils"
import { Separator } from "@/examples/radix/ui-rtl/separator"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"

const buttonGroupVariants = cva(
  "has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-e-lg 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:
          "[&>[data-slot]:not(:has(~[data-slot]))]:rounded-e-lg! [&>*:not(:first-child)]:rounded-s-none [&>*:not(:first-child)]:border-s-0 [&>*:not(:last-child)]:rounded-e-none",
        vertical:
          "[&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! 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-lg border px-2.5 text-sm font-medium [&_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 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 DocumentationAtlas domain, Changelog 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/examples/radix/ui-rtl/button-group.tsx (domain: DocumentationAtlas, subdomain: Changelog, 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