Button Group
muffled-ui-registry/button-groupFreeComponent
Grouped actions with shared borders on ink and paper. Horizontal and vertical layouts.
Live preview
live · rendered by the registry
Rendered by muffled-ui-registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.muffled.studio/r/button-group.jsonSource
1import { mergeProps } from "@base-ui/react/merge-props"2import { useRender } from "@base-ui/react/use-render"3import { cva, type VariantProps } from "class-variance-authority"45import { cn } from "@/registry/lib/surface"6import { Separator } from "@/registry/ui/separator"78const buttonGroupVariants = cva(9 "group/button-group flex w-fit items-stretch *: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-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",10 {11 variants: {12 orientation: {13 horizontal:14 "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg!",15 vertical:16 "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg!",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(51 "flex items-center gap-2 rounded-lg border bg-muted px-2.5 text-sm font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",52 className53 ),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 "relative self-stretch bg-input 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// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from muffled-ui-registry
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | muffled-ui-registry | Components | Free | 2 deps | |
| Alertalert | muffled-ui-registry | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | muffled-ui-registry | Components | Free | 1 dep | |
| Avataravatar | muffled-ui-registry | Components | Free | 1 dep | |
| Badgebadge | muffled-ui-registry | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | muffled-ui-registry | Components | Free | 2 deps | |
| Buttonbutton | muffled-ui-registry | Components | Free | 2 deps | |
| Calendarcalendar | muffled-ui-registry | Components | Free | 2 deps |
