Skip to content
Unkey Design Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Alert banner

An in-page message that requires user attention.

import { IconTriangleWarningOutline18 } 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">
        <IconTriangleWarningOutline18 className="size-3.5" />
        <AlertBannerTitle>Deployment failed</AlertBannerTitle>
        <AlertBannerActions>
          <Button variant="outline" size="md">
            View logs
          </Button>
        </AlertBannerActions>
      </AlertBanner>
      <AlertBanner variant="error">
        <IconTriangleWarningOutline18 className="size-3.5" />
        <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.

Card appearance

import { IconTriangleWarningOutline18 } from "@unkey/icons";
import {
  AlertBanner,
  AlertBannerActions,
  AlertBannerDescription,
  AlertBannerMeta,
  AlertBannerTitle,
} from "@unkey/ui";

export default function AlertBannerCard() {
  return (
    <div className="flex flex-col gap-3">
      <AlertBanner variant="warning" appearance="card">
        <IconTriangleWarningOutline18 className="size-4" />
        <AlertBannerTitle>Out of memory</AlertBannerTitle>
        <AlertBannerMeta>5 restarts · 54 minutes ago</AlertBannerMeta>
        <AlertBannerActions>
          <a href="#logs" className="font-medium text-gray-11 text-xs hover:text-gray-12">
            View logs
          </a>
        </AlertBannerActions>
        <AlertBannerDescription>
          Your app hit its memory limit. Fix a leak or raise the limit.
        </AlertBannerDescription>
      </AlertBanner>
      <AlertBanner variant="error" appearance="card">
        <IconTriangleWarningOutline18 className="size-4" />
        <AlertBannerTitle>Crashing</AlertBannerTitle>
        <AlertBannerMeta>9 restarts · 2 minutes ago</AlertBannerMeta>
        <AlertBannerDescription>
          Your app exits right after it starts. Check your logs.
        </AlertBannerDescription>
      </AlertBanner>
    </div>
  );
}

Use appearance="card" for a problem with one resource, shown inline in a detail view: an instance that ran out of memory, a build that failed. The card stays white with a faint tint and border. Only the icon carries the colour, so it does not shout next to charts and metadata.

Put short facts such as counts and times in AlertBannerMeta, next to the title. Keep the description to one line. Use warning when the resource needs attention. Use error when it is broken or blocked now.

FYI

Do not confuse this with Alert, which is the older dialog primitive in @unkey/ui.