Capítulo 55 de 108
Callout estático para chamar atenção do usuário (não é toast, não some sozinho; fica fixo no layout). Não usa Base UI (é um componente puramente visual, sem primitiva JS por trás).
variant = "default" | "destructive".Alert (junto com o ícone, sem wrapper de header como em Dialog/Card).Button) posicionado absolutamente no canto superior direito do alert.lucide-react) é passado como primeiro filho direto de Alert, sem componente wrapper dedicado — o CSS do Alert já posiciona automaticamente.<Alert variant="destructive" className="max-w-md">
<AlertCircleIcon />
<AlertTitle>Payment failed</AlertTitle>
<AlertDescription>
Your payment could not be processed. Please check your payment method and try again.
</AlertDescription>
</Alert>
<Alert className="max-w-md">
<AlertTitle>Dark mode is now available</AlertTitle>
<AlertDescription>Enable it under your profile settings to get started.</AlertDescription>
<AlertAction>
<Button size="xs" variant="default">Enable</Button>
</AlertAction>
</Alert>
AlertAction adicionando um botão de ação posicionado no canto superior direito.<Alert className="max-w-md border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-50">
<AlertTriangleIcon />
<AlertTitle>Your subscription will expire in 3 days.</AlertTitle>
<AlertDescription>Renew now to avoid service interruption.</AlertDescription>
</Alert>
Alert, já que só existem as variantes default/destructive nativamente.Composição:
Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertAction
| Componente | Prop | Type | Default |
|---|---|---|---|
Alert | variant | "default" | "destructive" | "default" |
AlertTitle | className | string | - |
AlertDescription | className | string | - |
AlertAction | className | string | - |
Sonner/toast, não do Alert (que é estático e fica no fluxo do layout).default, destructive); para outras cores (warning/amber, info/blue), aplicar classes Tailwind diretamente via className.Alert junto com AlertTitle/AlertDescription.AlertAction posiciona a ação absolutamente no canto superior direito — não precisa de flex/justify manual.