Alert

A contextual notification component for displaying important messages. Alert uses the Panel core component as its surface layer, providing the same theming system — feedback colors, border styles, and radius control — while adding its own structured layout with an icon slot, optional title, optional actions, and a content area.

Feedback Colors

Alerts default to a neutral (primary) color palette and support semantic feedback colors: success, warning, and danger. Each feedback type automatically selects an appropriate icon.

This is a general information alert. Use it to surface important context or status updates to the user.
Your changes have been saved successfully. The update is now live.
Your session is about to expire. Save your work to avoid losing any changes.
Unable to complete the request. Please check your connection and try again.
---
import Alert from "../Alert.astro";
import { stack } from "@pindoba/styled-system/patterns";
---

<div class={stack({ gap: "md", direction: "column", width: "100%" })}>
  <Alert>
    This is a general information alert. Use it to surface important context or
    status updates to the user.
  </Alert>
  <Alert feedback="success">
    Your changes have been saved successfully. The update is now live.
  </Alert>
  <Alert feedback="warning">
    Your session is about to expire. Save your work to avoid losing any changes.
  </Alert>
  <Alert feedback="danger">
    Unable to complete the request. Please check your connection and try again.
  </Alert>
</div>

Emphasis

The emphasis prop controls the visual weight of the outer container:

  • primary (default) — full-color outer ring using the feedback color (500) with contrast text, and a tinted content area
  • secondary — neutral sunken outer container with a full-color icon, keeping the background quiet
  • tertiary — neutral sunken outer container with a neutral-background icon tinted by the feedback color

Primary

Full-color outer container — the feedback color (500) fills the outer ring with contrast text. The content area uses a tinted surface.
Full-color outer container — warning color fills the outer ring.
Full-color outer container — danger color fills the outer ring.

Secondary

Neutral sunken outer container with a colored icon. Provides clear feedback without a dominant colored background.
Neutral sunken outer container with a warning-colored icon.
Neutral sunken outer container with a danger-colored icon.

Tertiary

Neutral sunken container with a subtle content area. The icon uses a neutral background with the feedback color as the icon tint.
Neutral sunken container with a warning-tinted icon on a neutral background.
Neutral sunken container with a danger-tinted icon on a neutral background.
---
import Alert from "../Alert.astro";
import { stack } from "@pindoba/styled-system/patterns";
---

<div class={stack({ gap: "xl", direction: "column", width: "100%" })}>
  <div>
    <h3>Primary</h3>
    <div class={stack({ gap: "md", direction: "column", width: "100%" })}>
      <Alert feedback="success" emphasis="primary">
        Full-color outer container — the feedback color (500) fills the outer
        ring with contrast text. The content area uses a tinted surface.
      </Alert>
      <Alert feedback="warning" emphasis="primary">
        Full-color outer container — warning color fills the outer ring.
      </Alert>
      <Alert feedback="danger" emphasis="primary">
        Full-color outer container — danger color fills the outer ring.
      </Alert>
    </div>
  </div>

  <div>
    <h3>Secondary</h3>
    <div class={stack({ gap: "md", direction: "column", width: "100%" })}>
      <Alert feedback="success" emphasis="secondary">
        Neutral sunken outer container with a colored icon. Provides clear
        feedback without a dominant colored background.
      </Alert>
      <Alert feedback="warning" emphasis="secondary">
        Neutral sunken outer container with a warning-colored icon.
      </Alert>
      <Alert feedback="danger" emphasis="secondary">
        Neutral sunken outer container with a danger-colored icon.
      </Alert>
    </div>
  </div>

  <div>
    <h3>Tertiary</h3>
    <div class={stack({ gap: "md", direction: "column", width: "100%" })}>
      <Alert feedback="success" emphasis="tertiary">
        Neutral sunken container with a subtle content area. The icon uses a
        neutral background with the feedback color as the icon tint.
      </Alert>
      <Alert feedback="warning" emphasis="tertiary">
        Neutral sunken container with a warning-tinted icon on a neutral
        background.
      </Alert>
      <Alert feedback="danger" emphasis="tertiary">
        Neutral sunken container with a danger-tinted icon on a neutral
        background.
      </Alert>
    </div>
  </div>
</div>

Icon

Alerts display a feedback-appropriate icon by default. Use noIcon to hide it when the content provides sufficient visual context.

An alert without an icon. Useful when the content itself provides enough visual context.
Operation completed. The icon is hidden — the feedback color alone conveys the status.
Proceeding may have unintended side effects. Review before continuing.
This action cannot be undone. All associated data will be permanently deleted.
---
import Alert from "../Alert.astro";
import { stack } from "@pindoba/styled-system/patterns";
---

<div class={stack({ gap: "md", direction: "column", width: "100%" })}>
  <Alert noIcon>
    An alert without an icon. Useful when the content itself provides enough
    visual context.
  </Alert>
  <Alert feedback="success" noIcon>
    Operation completed. The icon is hidden — the feedback color alone conveys
    the status.
  </Alert>
  <Alert feedback="warning" emphasis="secondary" noIcon>
    Proceeding may have unintended side effects. Review before continuing.
  </Alert>
  <Alert feedback="danger" emphasis="tertiary" noIcon>
    This action cannot be undone. All associated data will be permanently
    deleted.
  </Alert>
</div>

Title and Actions

The title prop and actions slot switch the header to column layout: the icon and title appear in a top row, followed by the content below. In Svelte, actions is a snippet; in Astro, use slot="actions".

Heads up

Adding a title switches the layout to column mode — the header row contains the icon and title, and the content appears below.

Changes saved

Your profile has been updated and the changes are now live.

Session expiring

Your session will expire in 5 minutes. Save your work or extend the session.

Permission denied

You do not have permission to perform this action. Contact your administrator for access.
---
import Alert from "../Alert.astro";
import Button from "@pindoba/astro-button";
import { Icon } from "astro-icon/components";
import { stack } from "@pindoba/styled-system/patterns";
---

<div class={stack({ gap: "md", direction: "column", width: "100%" })}>
  <Alert title="Heads up">
    Adding a title switches the layout to column mode — the header row contains
    the icon and title, and the content appears below.
  </Alert>

  <Alert feedback="success" title="Changes saved">
    <Button slot="actions" size="xs" shape="square" emphasis="ghost">
      <Icon name="lucide:x" width={14} height={14} />
    </Button>
    Your profile has been updated and the changes are now live.
  </Alert>

  <Alert feedback="warning" emphasis="secondary" title="Session expiring">
    <Button slot="actions" size="xs" feedback="warning" emphasis="secondary">
      Extend
    </Button>
    <Button slot="actions" size="xs" shape="square" emphasis="ghost">
      <Icon name="lucide:x" width={14} height={14} />
    </Button>
    Your session will expire in 5 minutes. Save your work or extend the session.
  </Alert>

  <Alert feedback="danger" emphasis="tertiary" title="Permission denied">
    <Button slot="actions" size="xs" shape="square" emphasis="ghost">
      <Icon name="lucide:x" width={14} height={14} />
    </Button>
    You do not have permission to perform this action. Contact your administrator
    for access.
  </Alert>
</div>

Custom Styling

The border, radius, and padding props are forwarded to Panel, enabling direct control over the outer container surface. The passThrough prop provides escape hatches for advanced customization: style accepts any Panda CSS SystemStyleObject applied to any slot, and props forwards arbitrary HTML attributes.

Using border="bold" and radius="md" to override the default border and corner rounding.
Using padding="md" for a more compact outer container.
Using passThrough to constrain the width and italicize the content text.
Using passThrough.root.props to add ARIA attributes for accessibility.
---
import Alert from "../Alert.astro";
import { stack } from "@pindoba/styled-system/patterns";
import { css } from "@pindoba/styled-system/css";
---

<div class={stack({ gap: "md", direction: "column", width: "100%" })}>
  <!-- Custom border and radius via Panel props -->
  <Alert
    feedback="success"
    border="bold"
    radius="md"
    passThrough={{
      content: {
        style: css.raw({ borderRadius: "sm", borderTopLeftRadius: "2xs" }),
      },
      icon: {
        style: css.raw({ borderRadius: "sm", borderTopRightRadius: "2xs" }),
      },
    }}
  >
    Using <code>border="bold"</code> and <code>radius="md"</code> to override the
    default border and corner rounding.
  </Alert>

  <!-- Custom padding -->
  <Alert feedback="warning" emphasis="secondary" padding="md">
    Using <code>padding="md"</code> for a more compact outer container.
  </Alert>

  <!-- Custom styles via passThrough -->
  <Alert
    feedback="danger"
    emphasis="tertiary"
    passThrough={{
      root: { style: { maxWidth: "480px" } },
      content: { style: { fontStyle: "italic" } },
    }}
  >
    Using <code>passThrough</code> to constrain the width and italicize the content
    text.
  </Alert>

  <!-- ARIA attributes via passThrough props -->
  <Alert
    feedback="success"
    emphasis="secondary"
    passThrough={{
      root: {
        props: {
          role: "status",
          "aria-live": "polite",
          "aria-label": "Status notification",
        },
      },
    }}
  >
    Using <code>passThrough.root.props</code> to add ARIA attributes for accessibility.
  </Alert>
</div>

Props

Prop
feedback
feedback

Semantic feedback color scheme. When omitted, the alert uses the primary color palette (general information). Providing a feedback color applies the corresponding color tokens and icon.

Type "success" | "warning" | "danger" | "default"
Default "default"
Required No
emphasis
emphasis

Controls the visual weight of the outer container. primary: full-color (500) outer ring with contrast text and a tinted content area. secondary: neutral sunken outer with a full-color icon. tertiary: neutral sunken outer with a neutral-background icon tinted by the feedback color.

Type "primary" | "secondary" | "tertiary"
Default "primary"
Required No
size
size

Font size for the alert text. sm: smaller text for compact layouts. md: default size. lg: larger text for prominent alerts.

Type "sm" | "md" | "lg"
Default "md"
Required No
noIcon
noIcon

When true, hides the feedback icon from the alert.

Type boolean
Default false
Required No
border
border

Box-shadow ring border forwarded to Panel. none: no border. default: standard border. bold: stronger emphasis. muted: subtle separation. Defaults to none for primary emphasis and muted for secondary/tertiary.

Type "none" | "default" | "bold" | "muted"
Default automatic
Required No
radius
radius

Border radius of the outer container, forwarded to Panel.

Type "none" | "5xs" | "4xs" | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "11xl" | "full"
Default "xs"
Required No
padding
padding

Internal padding of the outer container, forwarded to Panel.

Type "none" | "5xs" | "4xs" | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "11xl"
Default "2xs"
Required No
translucent
translucent

Apply a frosted glass effect with backdrop blur to the outer container.

Type boolean
Default false
Required No
title
title

Optional title displayed in the header row. When present, the layout switches to column mode.

Type string
Default undefined
Required No
actions
actions

Content rendered in the header row, aligned to the trailing edge. Useful for dismiss buttons or action links. In Svelte, pass a snippet; in Astro, use slot="actions".

Type Snippet | slot
Default undefined
Required No
passThrough
passThrough

Custom styling and props for alert slots. Each slot accepts style (SystemStyleObject) and props (HTML attributes).

Type { root?: { style?: SystemStyleObject; props?: HTMLAttributes<HTMLDivElement> & Record<string, unknown> }; header?: { style?: SystemStyleObject }; icon?: { style?: SystemStyleObject; props?: HTMLAttributes<HTMLDivElement> }; title?: { style?: SystemStyleObject; props?: HTMLAttributes<HTMLHeadingElement> }; actions?: { style?: SystemStyleObject; props?: HTMLAttributes<HTMLDivElement> }; content?: { style?: SystemStyleObject; props?: HTMLAttributes<HTMLDivElement> } }
Default undefined
Required No
...rest
...rest

Standard HTML div attributes

Type HTMLAttributes<HTMLDivElement>
Default -
Required No