Alert for Astro
Inline Astro feedback with message, action, and semantic status styles.
Installation
bunx --bun shadcn@latest add @gnostic/alertnpx shadcn@latest add @gnostic/alertpnpm dlx shadcn@latest add @gnostic/alertCopy the files
src/components/ui/alert/alert-variants.tssrc/components/ui/alert/alert-action.astrosrc/components/ui/alert/alert-description.astrosrc/components/ui/alert/alert-title.astrosrc/components/ui/alert/alert.astrosrc/components/ui/alert/index.ts
Usage
import { Alert, AlertAction, AlertDescription, AlertTitle } from "@/components/ui/alert"
<Alert variant="default">
<Terminal />
<AlertTitle>Content review is ready</AlertTitle>
<AlertDescription>
Three pages have updated copy. Review the changes before publishing.
</AlertDescription>
</Alert>
Example
Use AlertAction when the alert should include a secondary control such as a
button.
Composition
Arrange the parts as shown for an Alert:
Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertAction
Notes
- Use
Alertfor inline feedback inside the page flow. - Use
variant="error"for a failed action andvariant="warning"for a condition that needs attention.destructiveuses the selected preset’s destructive recipe;errorkeeps the Gnostic status treatment. - For destructive confirmation flows, use Alert Dialog instead.
API Reference
Read the installed source for the complete prop types.
When to use Alert
Use an Alert near the content that needs attention. Put the main fact in AlertTitle, then put the cause or next step in AlertDescription. An optional icon is a direct child. Add AlertAction only when a short action helps the reader resolve the message. An Alert stays in the page layout; it is not a toast service.
Keyboard and behavior
The root has role="alert" by default. Reserve an interrupting announcement for an urgent change. For an ordinary static note, pass an appropriate role such as role="note". The component has no dismissal or notification queue script. A button inside an alert keeps its native keyboard behavior.
Theme and layout
Choose info, success, warning, or error to match the message. default and destructive use the selected preset’s recipes. Status variants keep their Gnostic treatment and use the shared semantic tokens. State the result in text as well as color. Shared semantic tokens control the border, icon, and tint in both color modes; the neutral variant suits general page guidance.