AlertDialog
alertdialog-1779354227255.tsx
'use client';
import React, { useState } from 'react';
interface AlertDialogProps {
isOpen: boolean;
onClose: () => void;
onConfirm: () => void;
title: string;
description: string;
}
const AlertDialog: React.FC<AlertDialogProps> = ({
isOpen,
onClose,
onConfirm,
title,
description,
}) => {
if (!isOpen) return null;
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Escape') {
onClose();
}
};
React.useEffect(() => {
document.addEventListener('keydown', handleKeyDown);
return () => document.removeEventListener('keydown', handleKeyDown);
}, []);
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-zinc-950 bg-opacity-90 backdrop-blur-sm"
onClick={onClose}
>
<div
className="mx-auto w-full max-w-md rounded-lg bg-zinc-950 p-6 shadow-2xl"
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-center justify-center">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-8 w-8 text-yellow-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
</div>
<h2 className="mt-4 text-lg font-medium text-yellow-500">{title}</h2>
<p className="mt-2 text-sm text-zinc-400">{description}</p>
<div className="mt-6 flex justify-end space-x-4">
<button
className="rounded-lg bg-zinc-800 py-2 px-4 text-sm text-zinc-400 hover:bg-zinc-700"
onClick={onClose}
>
Cancel
</button>
<button
className="rounded-lg bg-yellow-500 py-2 px-4 text-sm text-zinc-950 hover:bg-yellow-600"
onClick={onConfirm}
>
Confirm
</button>
</div>
</div>
</div>
);
};
export default AlertDialog;Component info
CategoryOverlays
Frameworkreact
TierFREE
Views0
Copies0
About
Confirmation alert dialog modal
More from Overlays
'use client';
import { useState } from 'react';
interface BottomSheetProps {
isOpen: boolean;
onClose: () => void;
}
const BottomSheet = ({ isOpen, onClose }: BottomSheetProps) => {
const [isDragging, setIsDragging] = useState(false);
consBottomSheet
Overlays
import React, { useState } from 'react';
import './SlideDrawer.css';
interface SlideDrawerProps {
isOpen: boolean;
onClose: () => void;
children: React.ReactNode;
}
const SlideDrawer: React.FC<SlideDrawerProps> = ({ isOpen, onClose, children SlideDrawer
Overlays
import React, { useState } from 'react';
interface ContextMenuProps {
children: React.ReactNode;
}
const ContextMenu: React.FC<ContextMenuProps> = ({ children }) => {
const [showMenu, setShowMenu] = useState(false);
const [x, setX] = useStateContextMenu
Overlays
'use client';
import { useState, useEffect } from 'react';
interface Command {
id: number;
title: string;
description: string;
}
const commands: Command[] = [
{ id: 1, title: 'New File', description: 'Create a new file' },
{ id: 2, titleCommandPalette
Overlays