Alert
Coloured messages for news, updates, errors, success and warnings.
Coloured messages for news, updates, errors, success and warnings.
npm install @heroui/react
First time with HeroUI? Set it up once.
/**
* Demo from HeroUI, https://heroui.com (docs example alert/basic.tsx).
* Apache-2.0, Copyright 2025 NextUI Inc. Full text: https://github.com/heroui-inc/heroui/blob/main/LICENSE
* Changed for Tastebud: a default export (HeroUI's docs use named ones).
*/
import {Alert, Button, CloseButton, Spinner} from "@heroui/react";
import React from "react";
export default function AlertDemo() {
return (
<div className="grid w-full max-w-xl gap-4">
{/* Default - General information */}
<Alert>
<Alert.Indicator />
<Alert.Content>
<Alert.Title>New features available</Alert.Title>
<Alert.Description>
Check out our latest updates including dark mode support and improved accessibility
features.
</Alert.Description>
</Alert.Content>
</Alert>
{/* Accent - Important information with action */}
<Alert status="accent">
<Alert.Indicator />
<Alert.Content>
<Alert.Title>Update available</Alert.Title>
<Alert.Description>
A new version of the application is available. Please refresh to get the latest features
and bug fixes.
</Alert.Description>
<Button className="mt-2 sm:hidden" size="sm" variant="primary">
Refresh
</Button>
</Alert.Content>
<Button className="hidden sm:block" size="sm" variant="primary">
Refresh
</Button>
</Alert>
{/* Danger - Error with detailed steps */}
<Alert status="danger">
<Alert.Indicator />
<Alert.Content>
<Alert.Title>Unable to connect to server</Alert.Title>
<Alert.Description>
We're experiencing connection issues. Please try the following:
<ul className="mt-2 list-inside list-disc space-y-1 text-sm">
<li>Check your internet connection</li>
<li>Refresh the page</li>
<li>Clear your browser cache</li>
</ul>
</Alert.Description>
<Button className="mt-2 sm:hidden" size="sm" variant="danger">
Retry
</Button>
</Alert.Content>
<Button className="hidden sm:block" size="sm" variant="danger">
Retry
</Button>
</Alert>
{/* Without description */}
<Alert status="success">
<Alert.Indicator />
<Alert.Content>
<Alert.Title>Profile updated successfully</Alert.Title>
</Alert.Content>
<CloseButton />
</Alert>
{/* Custom indicator - Loading state */}
<Alert status="accent">
<Alert.Indicator>
<Spinner size="sm" />
</Alert.Indicator>
<Alert.Content>
<Alert.Title>Processing your request</Alert.Title>
<Alert.Description>
Please wait while we sync your data. This may take a few moments.
</Alert.Description>
</Alert.Content>
</Alert>
{/* Without close button */}
<Alert status="warning">
<Alert.Indicator />
<Alert.Content>
<Alert.Title>Scheduled maintenance</Alert.Title>
<Alert.Description>
Our services will be unavailable on Sunday, March 15th from 2:00 AM to 6:00 AM UTC for
scheduled maintenance.
</Alert.Description>
</Alert.Content>
</Alert>
</div>
);
}
Changed for this site: A default export (HeroUI's docs use named ones).