BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/basecn/button-group

Button Group

basecn/button-group
FreeComponent

A container that groups related buttons together with consistent styling.

Live preview

live · rendered by the registry
Rendered by basecn on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://basecn.dev/r/button-group.json

Source

src/registry/components/ui/button-group.tsxbasecn.dev/r/button-group.json
1import { mergeProps } from "@base-ui/react/merge-props";
2import { useRender } from "@base-ui/react/use-render";
3import { cva, type VariantProps } from "class-variance-authority";
4
5import { cn } from "@/lib/utils";
6import { Separator } from "@/registry/components/ui/separator";
7
8const buttonGroupVariants = cva(
9 "flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
10 {
11 variants: {
12 orientation: {
13 horizontal:
14 "*:not-[&:nth-child(1_of_:not([aria-hidden],span[data-base-ui-inert]))]:rounded-l-none *:not-[&:nth-child(1_of_:not([aria-hidden],span[data-base-ui-inert]))]:border-l-0 *:not-[&:nth-last-child(1_of_:not([aria-hidden],span[data-base-ui-inert]))]:rounded-r-none",
15 vertical:
16 "flex-col *:not-[&:nth-child(1_of_:not([aria-hidden],span[data-base-ui-inert]))]:rounded-t-none *:not-[&:nth-child(1_of_:not([aria-hidden],span[data-base-ui-inert]))]:border-t-0 *:not-[&:nth-last-child(1_of_:not([aria-hidden],span[data-base-ui-inert]))]:rounded-b-none",
17 },
18 },
19 defaultVariants: {
20 orientation: "horizontal",
21 },
22 }
23);
24
25function ButtonGroup({
26 className,
27 orientation,
28 ...props
29}: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
30 return (
31 <div
32 role="group"
33 data-slot="button-group"
34 data-orientation={orientation}
35 className={cn(buttonGroupVariants({ orientation }), className)}
36 {...props}
37 />
38 );
39}
40
41function ButtonGroupText({
42 className,
43 render,
44 ...props
45}: React.ComponentProps<"div"> & {
46 render?: useRender.RenderProp;
47}) {
48 return useRender({
49 defaultTagName: "div",
50 render,
51 props: mergeProps(
52 {
53 className: cn(
54 "bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
55 className
56 ),
57 },
58 props
59 ),
60 });
61}
62
63function ButtonGroupSeparator({
64 className,
65 orientation = "vertical",
66 ...props
67}: React.ComponentProps<typeof Separator>) {
68 return (
69 <Separator
70 data-slot="button-group-separator"
71 orientation={orientation}
72 className={cn(
73 "bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto",
74// … truncated

What it pulls in

npm packages

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

Other registry items

  • @basecn/separator

Files it writes

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

Facts

Registry
basecn
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on basecn basecn.dev akash3444/basecn on GitHub Raw registry item This item as JSON

More from basecn

All 56 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionbasecnComponentsFree2 deps
AlertalertbasecnComponentsFree1 dep
Alert Dialogalert-dialogbasecnComponentsFree1 dep
Aspect Ratioaspect-ratiobasecnComponentsFreeno deps
AutocompleteautocompletebasecnComponentsFree2 deps
AvataravatarbasecnComponentsFree1 dep
BadgebadgebasecnComponentsFree2 deps
BreadcrumbbreadcrumbbasecnComponentsFree2 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