Documentation menu
Getting Started
Components
Primitives
- Agent Thinking
- Alert
- Alert Dialog
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Command
- Command Palette
- Context Menu
- Data Table
- Dialog
- Dropdown Menu
- Empty
- Field
- Glow Cloud
- Input
- Label
- Medication Schedule
- Period Tabs
- Popover
- Rainbow Button
- Scroll Area
- Select
- Selectable Card
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag
- Textarea
- Timeline
- Tooltip
- Use Count Up
Charts and metrics
Patterns
- Confirm Button
- Date Picker
- Embedded
- Empty State
- Entity Drawer
- Error Boundary
- Field Row
- File Dropzone
- Form Dialog
- Kv
- List Editor
- List Page
- Live Time
- Mini Table
- Money
- Note Field
- Note Text
- Page Card
- Page Header
- Page Tabs
- Page Toolbar
- Person Cell
- Picture Field
- Print Card
- Range Switcher
- Row Actions
- Search Input
- Search Select
- Selected Box
- Signature Pad
- Status Badge
- Sub Nav Layout
- Suggest Input
- Tab Icons
- Table Footer
- Theme Accent Picker
- Time Picker
- View All Link
Dashboard cards
Advanced
Device frames
Website widgets
Website screens
Website panels
Primitives
Button Group
Buttons joined into one control, with separators and text.
import { ChevronDown } from "lucide-react"
import { Button } from "@/registry/vcare/ui/button"
import { ButtonGroup, ButtonGroupSeparator } from "@/registry/vcare/ui/button-group"
export default function ButtonGroupDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-4">
<ButtonGroup>
<Button variant="outline">Day</Button>
<Button variant="outline">Week</Button>
<Button variant="outline">Month</Button>
</ButtonGroup>
<ButtonGroup>
<Button>Save bill</Button>
<ButtonGroupSeparator />
<Button size="icon" aria-label="More"><ChevronDown /></Button>
</ButtonGroup>
</div>
)
}Installation
npx shadcn@latest add @vcare/button-groupOr install directly from the URL: https://ui.vcarehms.com/r/button-group.json
- Install the dependencies:
npm i class-variance-authority radix-ui - Add the registry items it uses: separator, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/button-group.tsx
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/registry/vcare/lib/utils';
import { Slot } from 'radix-ui';
import { Separator } from '@/registry/vcare/ui/separator';
const buttonGroupVariants = cva(
"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-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
{
variants: {
orientation: {
horizontal: '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',
vertical: 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',
},
},
defaultVariants: {
orientation: 'horizontal',
},
},
);
function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>) {
return (
<div
role="group"
data-slot="button-group"
data-orientation={orientation}
className={cn(buttonGroupVariants({ orientation }), className)}
{...props}
/>
);
}
function ButtonGroupText({
className,
asChild = false,
render,
children,
...props
}: React.ComponentProps<'div'> & {
asChild?: boolean;
render?: React.ReactElement;
}) {
const Comp = asChild || render ? Slot.Root : 'div';
const content = render ? React.cloneElement(render, undefined, children ?? (render.props as { children?: React.ReactNode }).children) : children;
return (
<Comp
className={cn(
"flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
className,
)}
{...props}
>
{content}
</Comp>
);
}
function ButtonGroupSeparator({ className, orientation = 'vertical', ...props }: React.ComponentProps<typeof Separator>) {
return (
<Separator
data-slot="button-group-separator"
orientation={orientation}
className={cn('relative m-0! self-stretch bg-input data-[orientation=vertical]:h-auto', className)}
{...props}
/>
);
}
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };Usage
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "@/components/ui/button-group"Exports
ButtonGroup, ButtonGroupSeparator, ButtonGroupText
Dependencies
class-variance-authority@^0.7.1(npm)radix-ui@^1.8.1(npm)@vcare/separator(registry)@vcare/utils(registry)
Raw item: /r/button-group.json