Alert

A box that sets a short message apart from the page, in one row with an icon before it and an action after it when it needs them, in its tone's colour, info by default.

import { Alert, AlertTitle } from "@produkto/ui/Alert";

const Example = () => (
  <Alert className="max-w-sm">
    <AlertTitle>Title</AlertTitle>
  </Alert>
);

export default Example;

Usage

import { InformationCircleIcon } from "@hugeicons/core-free-icons";
import { Alert, AlertAction, AlertTitle } from "@produkto/ui/Alert";
import { Button } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";
<Alert>
  <Icon icon={InformationCircleIcon} />
  <AlertTitle>Title</AlertTitle>
  <AlertAction>
    <Button size="sm">Button</Button>
  </AlertAction>
</Alert>

Examples

Tones

tone sets the colour, info by default, accent, destructive, success or warning, each a light fill with its own line and words, as a badge is, and never a grey one.

import { Alert, AlertTitle, type AlertTone } from "@produkto/ui/Alert";

const tones: { tone: AlertTone; label: string }[] = [
  { tone: "accent", label: "Accent" },
  { tone: "destructive", label: "Destructive" },
  { tone: "success", label: "Success" },
  { tone: "warning", label: "Warning" },
  { tone: "info", label: "Info" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {tones.map((item) => (
      <Alert key={item.tone} tone={item.tone}>
        <AlertTitle>{item.label}</AlertTitle>
      </Alert>
    ))}
  </div>
);

export default Example;

Sizes

size sets the height, the side padding, the words and the icon as a button's: sm 32px tall, 8px in, with 12px words, base 40px, 12px in, with 14px words (the default), or lg 48px, 16px in, with 16px words; a small button beside the words fits without growing it, and an action's spacing follows.

import { Alert, AlertTitle, type AlertSize } from "@produkto/ui/Alert";

const sizes: { size: AlertSize; label: string }[] = [
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {sizes.map((item) => (
      <Alert key={item.size} size={item.size}>
        <AlertTitle>{item.label}</AlertTitle>
      </Alert>
    ))}
  </div>
);

export default Example;

Border radius

borderRadius sets the corners on the kit's one scale: none, xs 4px, sm 6px, base 8px, lg 12px (the default) or xl 16px.

import {
  Alert,
  AlertTitle,
  type AlertBorderRadius,
} from "@produkto/ui/Alert";

const radii: AlertBorderRadius[] = ["none", "xs", "sm", "base", "lg", "xl"];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {radii.map((borderRadius) => (
      <Alert key={borderRadius} borderRadius={borderRadius}>
        <AlertTitle>{borderRadius}</AlertTitle>
      </Alert>
    ))}
  </div>
);

export default Example;

With icon

An Icon as the first child sits before the title, centred on it, in the tone's colour.

import { InformationCircleIcon } from "@hugeicons/core-free-icons";
import { Alert, AlertTitle } from "@produkto/ui/Alert";
import { Icon } from "@produkto/ui/Icon";

const Example = () => (
  <Alert className="max-w-sm">
    <Icon icon={InformationCircleIcon} />
    <AlertTitle>Title</AlertTitle>
  </Alert>
);

export default Example;

Action

AlertAction sets a Link at the end of the row, underlined on hover, a button when it only acts and an address when it leads somewhere, centred on the title, which wraps before it.

import { Alert, AlertAction, AlertTitle } from "@produkto/ui/Alert";
import { Link } from "@produkto/ui/Link";

const Example = () => (
  <Alert className="max-w-sm">
    <AlertTitle>Title</AlertTitle>
    <AlertAction>
      <Link href="#">Link</Link>
    </AlertAction>
  </Alert>
);

export default Example;

API Reference

Alert

AlertProps · components/Alert/Alert.types.ts
PropTypeDefault
toneAlertTone"info"
sizeAlertSize"sm" | "base" | "lg""base"
borderRadiusAlertBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl""lg"

AlertTitle

AlertTitleProps · takes the props of <div>

AlertAction

AlertActionProps · takes the props of <div>

It also takes the props of <div>.