Skip to content
Myr

button-group.tsx

This file

Path

apps/web/src/components/ui/button-group.tsx

87 lines · 2.3 KiB · TypeScript

Last changed by

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

History of this file

Take it

Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a

lines 1–50why, one step back
1import { mergeProps } from "@base-ui/react/merge-props";
2import { useRender } from "@base-ui/react/use-render";3import { cva, type VariantProps } from "class-variance-authority";4import { cn } from "cn";56import { Separator } from "@/components/ui/separator";78const buttonGroupVariants = cva(9 "flex w-fit items-stretch rounded-none *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-none [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",10 {11 variants: {12 orientation: {13 horizontal:14 "*:data-slot:rounded-r-none [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0",15 vertical:16 "flex-col *:data-slot:rounded-b-none [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0",17 },18 },19 defaultVariants: {20 orientation: "horizontal",21 },22 }23);2425function ButtonGroup({26 className,27 orientation,28 ...props29}: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {30 return (31 <div32 role="group"33 data-slot="button-group"34 data-orientation={orientation}35 className={cn(buttonGroupVariants({ orientation }), className)}36 {...props}37 />38 );39}4041function ButtonGroupText({42 className,43 render,44 ...props45}: useRender.ComponentProps<"div">) {46 return useRender({47 defaultTagName: "div",48 props: mergeProps<"div">(49 {50 className: cn(

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

line 51why, one step back
51 "bg-muted text-ui flex items-center gap-2 rounded-none border px-2.5 font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",

Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a

lines 52–87why, one step back
52 className
53 ),54 },55 props56 ),57 render,58 state: {59 slot: "button-group-text",60 },61 });62}6364function ButtonGroupSeparator({65 className,66 orientation = "vertical",67 ...props68}: React.ComponentProps<typeof Separator>) {69 return (70 <Separator71 data-slot="button-group-separator"72 orientation={orientation}73 className={cn(74 "bg-input relative self-stretch data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",75 className76 )}77 {...props}78 />79 );80}8182export {83 ButtonGroup,84 ButtonGroupSeparator,85 ButtonGroupText,86 buttonGroupVariants,87};