Skip to content

Alert ​

Static status messages for important information, success confirmations, warnings, and errors.


Demo ​

Info

This is an informational message.

Success

Your changes have been saved successfully.

Warning with heading

Attention

Your session will expire in 5 minutes.

Error with heading

With footer

Dismissible

This alert can be dismissed.


When to use ​

  • Communicate status after an action (success, error)
  • Summarise form validation errors at the top of a form
  • Highlight important information or warnings within a page

When not to use ​

  • Temporary feedback that should auto-dismiss — use a toast/snackbar instead
  • Inline field-level validation — use error text on the input
  • Promotional banners or marketing content

Installation ​

bash
pnpm add @grundtone/vue

Usage ​

Basic ​

vue
<template>
  <GTAlert variant="info">
    <p>This is an informational message.</p>
  </GTAlert>
</template>

With icon ​

vue
<template>
  <GTAlert variant="success" icon="check-circle">
    <p>Your changes have been saved.</p>
  </GTAlert>
</template>

With heading ​

vue
<template>
  <GTAlert variant="error" icon="alert-circle" heading="Form errors">
    <p>Please fix the following errors before submitting.</p>
  </GTAlert>
</template>

Dismissible ​

vue
<script setup>
  import { ref } from 'vue';
  const show = ref(true);
</script>

<template>
  <GTAlert
    v-if="show"
    variant="info"
    icon="info-circle"
    dismissible
    @dismiss="show = false"
  >
    <p>This alert can be dismissed.</p>
  </GTAlert>
</template>

Props ​

PropTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'error'requiredVisual and semantic variant
headingstring—Optional heading above the body
iconstring—Icon name from the registry (renders GTIcon)
dismissiblebooleanfalseShow close/dismiss button
ariaLabelstring—Accessible label for the alert region

Events ​

EventPayloadDescription
dismiss—Emitted when the close button is clicked

Slots ​

SlotDescription
defaultAlert body content — supports rich text, links, lists
footerOptional footer content, separated by a line from the body

Accessibility ​

  • role="alert" for error variant (assertive — announced immediately)
  • role="status" for info, success, and warning (polite — announced at next opportunity)
  • Close button has aria-label="Close"
  • Icons are decorative (aria-hidden="true")

CSS Classes ​

ClassElement
.gt-alertRoot container
.gt-alert--infoInfo variant
.gt-alert--successSuccess variant
.gt-alert--warningWarning variant
.gt-alert--errorError variant
.gt-alert__iconIcon element
.gt-alert__contentContent wrapper (contains heading, body, footer)
.gt-alert__headingHeading paragraph (sibling of body)
.gt-alert__bodyBody content
.gt-alert__footerFooter with top border separator
.gt-alert__closeDismiss button

Design system ​

The CSS-only version of this component is documented in the Design System — Alert reference.