button-group
ora-ui/button-groupFreeComponent
ora-ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by ora-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ora-ui.com/r/button-group.jsonSource
1import { Slot } from '@radix-ui/react-slot';2import { cva, type VariantProps } from 'class-variance-authority';34import { cn } from '@/registry/lib/utils';5import { Separator } from '@/registry/ui/separator';67const buttonGroupVariants = cva(8 "flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 *:focus-visible:relative *:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-(--radius) [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",9 {10 variants: {11 orientation: {12 horizontal:13 '*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-dynamic! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0',14 vertical:15 'flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-dynamic! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0',16 },17 },18 defaultVariants: {19 orientation: 'horizontal',20 },21 }22);2324function ButtonGroup({25 className,26 orientation,27 ...props28}: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>) {29 return (30 <div31 role="group"32 data-slot="button-group"33 data-orientation={orientation}34 className={cn(buttonGroupVariants({ orientation }), className)}35 {...props}36 />37 );38}3940function ButtonGroupText({41 className,42 asChild = false,43 ...props44}: React.ComponentProps<'div'> & {45 asChild?: boolean;46}) {47 const Comp = asChild ? Slot : 'div';4849 return (50 <Comp51 className={cn(52 "bg-active flex items-center gap-2 rounded-dynamic border border-line-ui px-3 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",53 className54 )}55 {...props}56 />57 );58}5960function ButtonGroupSeparator({61 className,62 orientation = 'vertical',63 ...props64}: React.ComponentProps<typeof Separator>) {65 return (66 <Separator67 data-slot="button-group-separator"68 orientation={orientation}69 className={cn(70 'relative self-stretch bg-line-subtle [[data-variant=solid]+&]:bg-gray-950/85 [&:has(+[data-variant=solid])]:bg-gray-800 data-[orientation=vertical]:my-0! data-[orientation=vertical]:ml-px data-[orientation=vertical]:h-auto data-[orientation=horizontal]:mx-0! data-[orientation=horizontal]:mt-px data-[orientation=horizontal]:w-auto',71 className72 )}73// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from ora-ui
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | ora-ui | Components | Free | 2 deps | |
| alert-dialogalert-dialog | ora-ui | Components | Free | 1 dep | |
| avataravatar | ora-ui | Components | Free | 1 dep | |
| avatar-groupavatar-group | ora-ui | Components | Free | no deps | |
| badgebadge | ora-ui | Components | Free | 2 deps | |
| buttonbutton | ora-ui | Components | Free | 2 deps | |
| checkboxcheckbox | ora-ui | Components | Free | 3 deps | |
| checkbox-groupcheckbox-group | ora-ui | Components | Free | 1 dep |
