Model Card
A component for displaying modal cards. It provides a flexible and customizable interface for actions requiring confirmation.
Follow the installation and quick start below to use Model Card in your project, or read the complete setup guide.
On this page
Installation
1. Initialize once
Run from an existing React project with Node.js 18 or later. Skip this step if the project already has u-lib.json. Initialization copies the shared stylesheet and adds its import to your application entry.
npx @scriptwithahmad/u-lib@0.2.2 init2. Add Model Card and example components
This command includes the UI components used by this page's usage examples. The CLI copies editable source into your components directory and installs each component's dependencies. Existing source files are preserved.
npx @scriptwithahmad/u-lib@0.2.2 add alert-dialogChoose the tab for your package manager. Yarn commands require modern Yarn; Yarn Classic users can use npx. Use --dry-run to preview changes. See the installation guide for custom paths, JavaScript output and package-import alternatives.
Quick start
Copy this example into src/Example.tsx (or Example.tsx at the project root when you do not use src). Imports assume the default CLI paths. From a nested file such as src/app/page.tsx, adjust ./components to ../components. Keep the client directive in Next.js when using state or event handlers.
"use client";
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from "./components/ui/alert-dialog";
export default function UsageDemo() {
return (
<>
<AlertDialog>
<AlertDialogTrigger asChild>
<button className="rounded-md bg-primary px-4 py-2 text-primary-foreground">Open Modal</button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Modal Title</AlertDialogTitle>
<AlertDialogDescription>
Modal description goes here.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Confirm</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
);
}This catalog entry uses AlertDialog. Keep its title and description, and connect the confirmation action to your application logic.
Keep the shared stylesheet imported once. Replace sample image URLs and data with your own. Examples may use layout utilities beyond the precompiled component styles; compile added Tailwind classes in your app or replace them with your own CSS. Customize local source or className, and preserve accessible names and keyboard behavior.
Usage examples
Try each example, then switch to Code to copy its complete implementation. These catalog snippets use the website's @/components/ui alias; replace it with your local generated path as shown in Quick start.
Basic Usage
Use the modal to confirm actions like deletions or submissions.
Loading example…
Modal with Different Actions
Customize the footer actions for specific use cases.
Loading example…
Props & configuration
Everything you need to fine-tune this component.
| Prop | Type | Default | Description |
|---|---|---|---|
AlertDialog | React.Component | — | The root component that provides the dialog functionality. |
AlertDialogTrigger | React.Component | — | The trigger that opens the dialog. It wraps any element, typically a button. |
AlertDialogContent | React.Component | — | The main container for the modal content. |
AlertDialogHeader | React.HTMLAttributes<HTMLDivElement> | — | Defines the header section for the modal, including the title and description. |
AlertDialogFooter | React.HTMLAttributes<HTMLDivElement> | — | Defines the footer section, which typically contains action buttons like Cancel or Confirm. |
AlertDialogTitle | React.Component | — | The title of the modal, usually a brief description of the action being confirmed. |
AlertDialogDescription | React.Component | — | A detailed description or message about the action being confirmed. |
AlertDialogAction | React.Component | — | Represents the confirm or primary action button. |
AlertDialogCancel | React.Component | — | Represents the cancel button to close the dialog. |
