Alert banner
An in-page message that requires user attention.
import { TriangleWarning2 } from "@unkey/icons";
import {
AlertBanner,
AlertBannerActions,
AlertBannerDescription,
AlertBannerTitle,
Button,
} from "@unkey/ui";
export default function AlertBannerVariants() {
return (
<div className="flex flex-col gap-3">
<AlertBanner>
<AlertBannerDescription>
This project was imported from a Git repository.
</AlertBannerDescription>
</AlertBanner>
<AlertBanner variant="warning">
<AlertBannerTitle>Compute is paused</AlertBannerTitle>
<AlertBannerDescription>
Creating and deploying are paused without an active plan.
</AlertBannerDescription>
<AlertBannerActions>
<Button variant="outline" size="md">
Choose a plan
</Button>
</AlertBannerActions>
</AlertBanner>
<AlertBanner variant="error">
<TriangleWarning2 iconSize="md-regular" />
<AlertBannerTitle>Deployment failed</AlertBannerTitle>
<AlertBannerDescription>
The build could not resolve the git branch for this project.
</AlertBannerDescription>
<AlertBannerActions>
<Button variant="outline" size="md">
Redeploy
</Button>
</AlertBannerActions>
</AlertBanner>
</div>
);
}
Best practices
Content
Give the banner one job. Say what is wrong, then what to do about it, in that order. Keep the description to a sentence or two, and put the detail behind a link rather than in the banner.
Use a title when a short description alone does not identify the problem.
Use icons as sparingly as possible. Only add an icon to a banner if you feel like the content is not clear enough on it’s own.
Actions
Keep to one action. A second is acceptable when it dismisses or defers.
FYI
Do not confuse this with Alert, which is the older dialog primitive in @unkey/ui.