Confirmation Dialog
deso-ui/confirmation-dialogFreeBlock
A dialog for confirming user actions.
Install it
npx shadcn@latest add https://ui.deso.com/r/confirmation-dialog.jsonSource
1import * as React from 'react';2import {3 AlertDialog,4 AlertDialogAction,5 AlertDialogCancel,6 AlertDialogContent,7 AlertDialogDescription,8 AlertDialogFooter,9 AlertDialogHeader,10 AlertDialogTitle,11 AlertDialogTrigger,12} from '@/components/ui/alert-dialog';13import { buttonVariants } from '@/components/ui/button';14import { cn } from '@/lib/utils/deso';1516export interface ConfirmationDialogProps {17 trigger: React.ReactNode;18 title: React.ReactNode;19 description?: React.ReactNode;20 onConfirm: () => void;21 onCancel?: () => void;22 variant?: 'default' | 'success' | 'destructive';23 confirmText?: string;24 cancelText?: string;25 open?: boolean;26 onOpenChange?: (open: boolean) => void;27}2829export function ConfirmationDialog({30 trigger,31 title,32 description,33 onConfirm,34 onCancel,35 variant = 'default',36 confirmText = 'Confirm',37 cancelText = 'Cancel',38 open,39 onOpenChange,40}: ConfirmationDialogProps) {41 const confirmButtonVariant = variant === 'default' ? 'default' : variant;4243 return (44 <AlertDialog open={open} onOpenChange={onOpenChange}>45 <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger>46 <AlertDialogContent className="border border-border">47 <AlertDialogHeader>48 <AlertDialogTitle>{title}</AlertDialogTitle>49 {description && (50 <AlertDialogDescription>{description}</AlertDialogDescription>51 )}52 </AlertDialogHeader>53 <AlertDialogFooter>54 <AlertDialogCancel onClick={onCancel}>{cancelText}</AlertDialogCancel>55 <AlertDialogAction56 onClick={onConfirm}57 className={cn(buttonVariants({ variant: confirmButtonVariant }))}58 >59 {confirmText}60 </AlertDialogAction>61 </AlertDialogFooter>62 </AlertDialogContent>63 </AlertDialog>64 );65}
Files it writes
More from deso-ui
All 47 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Menuaction-menu | deso-ui | Blocks | Free | no deps | |
| Copy Buttoncopy-button | deso-ui | Blocks | Free | no deps | |
| Editoreditor | deso-ui | Blocks | Free | no deps | |
| Editor Emoji Pickereditor-emoji-picker | deso-ui | Blocks | Free | no deps | |
| Editor Markdowneditor-markdown | deso-ui | Blocks | Free | no deps | |
| Editor Uploadeditor-upload | deso-ui | Blocks | Free | no deps | |
| Feed Listfeed-list | deso-ui | Blocks | Free | no deps | |
| Follow Buttonfollow-button | deso-ui | Blocks | Free | no deps |
