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
The main action control, in six variants and four sizes, with a press-scale effect.
import { Plus } from "lucide-react"
import { Button } from "@/registry/vcare/ui/button"
export default function ButtonDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2">
<Button>
<Plus /> New visit
</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="destructive">Delete</Button>
<Button variant="link">Link</Button>
</div>
)
}Installation
npx shadcn@latest add @vcare/buttonOr install directly from the URL: https://ui.vcarehms.com/r/button.json
- Install the dependencies:
npm i class-variance-authority radix-ui - Add the registry items it uses: render-compat, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/button.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 type { RenderProp } from '@/registry/vcare/lib/render-compat';
const buttonVariants = cva(
"inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-xl font-semibold leading-none whitespace-nowrap select-none outline-none transition-[scale,background-color,color,box-shadow,opacity] duration-150 ease-power3-out focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:focus-visible:outline-foreground disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground shadow-primary hover:bg-primary-hover',
secondary: 'bg-secondary text-secondary-foreground shadow-raised ring-1 ring-inset ring-primary/40 hover:bg-primary/10 hover:ring-primary/70 [&_svg]:text-primary dark:ring-foreground/25 dark:hover:bg-primary/20 dark:hover:ring-foreground/45 dark:[&_svg]:text-foreground',
outline: 'bg-secondary text-secondary-foreground shadow-raised ring-1 ring-inset ring-primary/40 hover:bg-primary/10 hover:ring-primary/70 [&_svg]:text-primary dark:ring-foreground/25 dark:hover:bg-primary/20 dark:hover:ring-foreground/45 dark:[&_svg]:text-foreground',
destructive: 'bg-destructive text-background hover:bg-destructive/90',
ghost: 'text-foreground/80 hover:bg-accent hover:text-foreground',
link: 'rounded-none text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-control px-3.5 text-[13px]',
xs: "h-control-sm px-2 text-xs [&_svg:not([class*='size-'])]:size-3",
sm: 'h-control-sm px-3 text-xs',
lg: 'h-control-lg px-4 text-sm',
icon: 'size-(--control-h) p-0',
'icon-xs': 'size-(--control-h-sm) p-0',
'icon-sm': 'size-(--control-h-sm) p-0',
'icon-lg': 'size-(--control-h-lg) p-0',
},
},
// A ghost button with words is still an action: a soft tint of the brand colour so it never reads as plain text.
// Icon-only ghost buttons (toolbars, row actions) stay plain.
compoundVariants: [
{
variant: 'ghost',
size: ['default', 'xs', 'sm', 'lg'],
className: 'bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary dark:bg-primary/30 dark:text-foreground dark:hover:bg-primary/45 dark:hover:text-foreground',
},
],
defaultVariants: { variant: 'default', size: 'default' },
},
);
function Button({
className,
variant = 'default',
size = 'default',
asChild = false,
static: isStatic = false,
render,
children,
...props
}: React.ComponentProps<'button'> &
RenderProp &
VariantProps<typeof buttonVariants> & {
asChild?: boolean;
/** Opt out of the press-scale feedback. */
static?: boolean;
}) {
const Comp = asChild || render ? Slot.Root : 'button';
const resolved = typeof render === 'function' ? render({}) : render;
const content = resolved
? React.cloneElement(resolved, undefined, children ?? (resolved.props as { children?: React.ReactNode }).children)
: children;
return (
<Comp
data-slot="button"
data-variant={variant}
data-size={size}
className={cn(buttonVariants({ variant, size }), !isStatic && 'active:not-disabled:scale-[0.96] motion-reduce:active:scale-100', className)}
{...props}
>
{content}
</Comp>
);
}
export { Button, buttonVariants };Usage
import { Button } from "@/components/ui/button"Examples
Exports
Button
Dependencies
class-variance-authority@^0.7.1(npm)radix-ui@^1.8.1(npm)@vcare/render-compat(registry)@vcare/utils(registry)
Raw item: /r/button.json