Alert
Displays a callout for user attention with optional action.
CMS Demo
See how content editors configure alerts in a CMS:
Loading...
CMS ConfigurationSimulates Payload CMS alert configuration
Payload Block Example
// In your Payload CMS blocks config
export const AlertBlock = {
slug: "alert",
fields: [
{ name: "title", type: "text", localized: true },
{ name: "description", type: "textarea", localized: true },
{
name: "variant",
type: "select",
options: [
{ label: "Default", value: "default" },
{ label: "Destructive", value: "destructive" },
],
},
{ name: "showAction", type: "checkbox" },
{ name: "actionLabel", type: "text", localized: true },
],
}Rendering the Alert
import {
Alert,
AlertTitle,
AlertDescription,
AlertAction,
} from "@mordecai-design-system/ui"
export function SystemAlert({ data }) {
return (
<Alert variant={data.variant}>
<AlertTitle>{data.title}</AlertTitle>
<AlertDescription>{data.description}</AlertDescription>
{data.showAction && (
<AlertAction>
<Button size="sm">{data.actionLabel}</Button>
</AlertAction>
)}
</Alert>
)
}Basic Usage
Loading...
AlertAlert with title and description
Installation
pnpm add @corew500/uiUsage
import {
Alert,
AlertTitle,
AlertDescription,
} from "@mordecai-design-system/ui"<Alert>
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
You can add components to your app using the CLI.
</AlertDescription>
</Alert>Examples
Destructive
<Alert variant="destructive">
<AlertTitle>Error</AlertTitle>
<AlertDescription>
Your session has expired. Please log in again.
</AlertDescription>
</Alert>With Icon
<Alert>
<Terminal className="size-4" />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
You can add components to your app using the CLI.
</AlertDescription>
</Alert>With Action
<Alert>
<AlertTitle>Update available</AlertTitle>
<AlertDescription>
A new version is available.
</AlertDescription>
<AlertAction>
<Button size="sm" variant="outline">Update</Button>
</AlertAction>
</Alert>Sub-components
| Component | Description |
|-----------|-------------|
| Alert | Root container with variant |
| AlertTitle | Alert heading |
| AlertDescription | Alert body text |
| AlertAction | Action button container |
Props
Alert
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | enum | — | — |