Button Group
uiable/button-groupFreeComponent
Button Group component.
Live preview
live · rendered by the registry
Rendered by uiable on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uiable.com/r/button-group.jsonSource
1"use client"23import { ComponentProps } from "react"4import { mergeProps } from "@base-ui/react/merge-props"5import { useRender } from "@base-ui/react/use-render"6import { cva, type VariantProps } from "class-variance-authority"78import { cn } from "@/lib/utils"9import { Separator } from "@/components/ui/separator"1011const buttonGroupVariants = cva(12 "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",13 {14 variants: {15 orientation: {16 horizontal:17 "*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0",18 vertical:19 "flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0",20 },21 },22 defaultVariants: {23 orientation: "horizontal",24 },25 }26)2728function ButtonGroup({29 className,30 orientation,31 ...props32}: ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {33 return (34 <div35 role="group"36 data-slot="button-group"37 data-orientation={orientation}38 className={cn(buttonGroupVariants({ orientation }), className)}39 {...props}40 />41 )42}4344function ButtonGroupText({45 className,46 render,47 ...props48}: useRender.ComponentProps<"div">) {49 return useRender({50 defaultTagName: "div",51 props: mergeProps<"div">(52 {53 className: cn(54 "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",55 className56 ),57 },58 props59 ),60 render,61 state: {62 slot: "button-group-text",63 },64 })65}6667function ButtonGroupSeparator({68 className,69 orientation = "vertical",70 ...props71}: ComponentProps<typeof Separator>) {72 return (73 <Separator74 data-slot="button-group-separator"75 orientation={orientation}76 className={cn(77 "relative self-stretch bg-input data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",78 className79 )}80 {...props}81// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from uiable
All 712 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | uiable | Components | Free | 2 deps | |
| Alertalert | uiable | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | uiable | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | uiable | Components | Free | no deps | |
| Attachmentattachment | uiable | Components | Free | 2 deps | |
| Avataravatar | uiable | Components | Free | 1 dep | |
| Badgebadge | uiable | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | uiable | Components | Free | 2 deps |
