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
Patterns
Confirm Button
A button that asks for confirmation before a destructive action.
import { ConfirmButton } from "@/registry/vcare/ui/confirm-button"
export default function ConfirmButtonDemo() {
return (
<ConfirmButton variant="destructive" title="Void this bill?" description="The invoice stays on record, marked void." onConfirm={() => undefined}>
Void bill
</ConfirmButton>
)
}Installation
npx shadcn@latest add @vcare/confirm-buttonOr install directly from the URL: https://ui.vcarehms.com/r/confirm-button.json
- Install the dependencies:
npm i class-variance-authority - Add the registry items it uses: alert-dialog, button, i18n.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/confirm-button.tsx
import type { ReactNode } from 'react';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/registry/vcare/ui/alert-dialog';
import { Button, type buttonVariants } from '@/registry/vcare/ui/button';
import type { VariantProps } from 'class-variance-authority';
/** Button that asks for confirmation before running a destructive/irreversible action. */
export function ConfirmButton({
children,
title,
description,
onConfirm,
variant = 'secondary',
disabled,
className,
}: {
children: ReactNode;
title: string;
description?: string;
onConfirm: () => void;
variant?: VariantProps<typeof buttonVariants>['variant'];
disabled?: boolean;
className?: string;
}) {
const { t } = useTranslation();
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant={variant} disabled={disabled} className={className}>
{children}
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{title}</AlertDialogTitle>
{description && <AlertDialogDescription>{description}</AlertDialogDescription>}
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('cancel')}</AlertDialogCancel>
<AlertDialogAction onClick={onConfirm}>{t('confirm')}</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}Usage
import { ConfirmButton } from "@/components/ui/confirm-button"Exports
ConfirmButton
Dependencies
class-variance-authority@^0.7.1(npm)@vcare/alert-dialog(registry)@vcare/button(registry)@vcare/i18n(registry)
Raw item: /r/confirm-button.json