BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/uiable/button-group

Button Group

uiable/button-group
FreeComponent

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.json

Source

src/components/ui/button-group.tsxuiable.com/r/button-group.json
1"use client"
2
3import { 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"
7
8import { cn } from "@/lib/utils"
9import { Separator } from "@/components/ui/separator"
10
11const 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)
27
28function ButtonGroup({
29 className,
30 orientation,
31 ...props
32}: ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
33 return (
34 <div
35 role="group"
36 data-slot="button-group"
37 data-orientation={orientation}
38 className={cn(buttonGroupVariants({ orientation }), className)}
39 {...props}
40 />
41 )
42}
43
44function ButtonGroupText({
45 className,
46 render,
47 ...props
48}: 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 className
56 ),
57 },
58 props
59 ),
60 render,
61 state: {
62 slot: "button-group-text",
63 },
64 })
65}
66
67function ButtonGroupSeparator({
68 className,
69 orientation = "vertical",
70 ...props
71}: ComponentProps<typeof Separator>) {
72 return (
73 <Separator
74 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 className
79 )}
80 {...props}
81// … truncated

What it pulls in

npm packages

  • @base-ui/react
  • class-variance-authority

Other registry items

  • @uiable/separator

Files it writes

  • src/components/ui/button-group.tsx

Facts

Registry
uiable
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

Docs on uiable uiable.com codedthemes/uiable on GitHub Raw registry item This item as JSON

More from uiable

All 712 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionuiableComponentsFree2 deps
AlertalertuiableComponentsFree1 dep
Alert Dialogalert-dialoguiableComponentsFree1 dep
Aspect Ratioaspect-ratiouiableComponentsFreeno deps
AttachmentattachmentuiableComponentsFree2 deps
AvataravataruiableComponentsFree1 dep
BadgebadgeuiableComponentsFree2 deps
BreadcrumbbreadcrumbuiableComponentsFree2 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex