Alert
Alert communicates important inline status, validation, or operational messages without interrupting the current workflow.
@duskmoon-dev/components/alert Usage
When to use
- Use it immediately after user actions or system checks that need visible confirmation.
- Choose the least interruptive feedback surface that still makes the state clear.
Implementation notes
Features
Covers transient, inline, or blocking feedback patterns for user actions and system status.
Shows how the component keeps next actions visible after success, warning, or failure states.
Alert is most often configured through `color`, `appearance`.
Renders children correctly
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
filled
outline
tonal
Colors
Alert supports the full semantic color palette: primary, secondary, tertiary, accent, neutral, base, info, success, warning, error.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
const colors = [
"primary",
"secondary",
"tertiary",
"accent",
"neutral",
"base",
"info",
"success",
"warning",
"error"
] as const;
export function AlertColorsDemo() {
return (<div style={{ display: "grid", gap: 12 }}>
{(["filled", "outline", "tonal"] as const).map((appearance) => (
<section key={appearance} style={{ display: "grid", gap: 8 }}>
{colors.map((color) => (
<Alert key={color} color={color} appearance={appearance}>
{color} alert
</Alert>
))}
</section>
))}
</div>);
} Basic usage
Import the component stylesheet and Alert from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
export function Example() {
return (<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>);
} Renders children correctly
test-backedAlert scenario from the component test coverage: renders children correctly.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
export function AlertRendersChildrenCorrectlyDemo() {
return (<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>);
} Applies default classes
test-backedAlert scenario from the component test coverage: applies default classes.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
export function AlertAppliesDefaultClassesDemo() {
return (<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>);
} filled
outline
tonal
Applies color and appearance classes
test-backedAlert scenario from the component test coverage: applies color and appearance classes.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
export function AlertAppliesColorAndAppearanceDemo() {
return (<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>);
} Maps tonal appearance to the base container style
test-backedAlert scenario from the component test coverage: maps tonal appearance to the base container style.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
export function AlertMapsTonalAppearanceToDemo() {
return (<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>);
} Applies custom className
test-backedAlert scenario from the component test coverage: applies custom classname.
import "@duskmoon-dev/components/styles.css";
import { Alert } from "@duskmoon-dev/components/alert";
export function AlertAppliesCustomClassNameDemo() {
return (<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>
</div>
<div data-theme="moonlight">
<Alert color="success" appearance="tonal">
Release checks passed.
</Alert>
</div> API
The API reference below lists every parsed exported type or interface for Alert. Start with `color`, `appearance` for common usage.
packages/components/src/components/alert/Alert.types.ts
Scenarios: packages/components/src/components/alert/Alert.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
color | AlertColor | No | color configures Alert. |
appearance | AlertAppearance | No | appearance configures Alert. |
| "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error" "filled" | "outline" | "tonal"