Alert

Communicates a contextual, timely system message that needs a user's attention.

On this page

This docs is LLM-friendly and available as clean Markdown.

Supported browser agents can also use WebMCP to search, read, and open these docs. Learn more

Usage

import {
  GlAlert,
  GlAlertActions,
  GlAlertDescription,
} from "gitlab-ui-react/alert";
import { GlButton } from "gitlab-ui-react/button";
<GlAlert dismissible={false}>
  <GlAlertDescription>Your preferences were updated.</GlAlertDescription>
  <GlAlertActions>
    <GlButton>Review changes</GlButton>
  </GlAlertActions>
</GlAlert>

Default

Use an alert for a dynamic system condition in the current context. Start with a non-dismissible alert when the message must remain available until its underlying condition is resolved.

Information alert
Your preferences were updated and will apply to new projects.

Dismissible alerts

Allow dismissal only when the message can safely be removed. GlAlert does not hide itself, so the parent must update its state and remove the alert when onDismiss runs.

Dismissible information alert
Your preferences were updated and will apply to new projects.

Variants

Choose a variant for the message’s meaning, not merely its visual emphasis. Use danger for critical problems, warning for risks, success for outcomes completed elsewhere, information for changing status, and tip for useful product guidance.

Alert variants

Pipeline is running

This page updates as jobs finish.

Save time with templates

Start from a template when creating a new issue.

Titles and actions

Add a short title when it helps users identify what triggered the alert. Put up to two explicit recovery or continuation controls in GlAlertActions; use a confirm primary action and a default secondary action.

Alert with actions

Accessibility

  • Use alerts for dynamic notifications, not permanently visible documentation or contextual help.
  • Danger, warning, and success variants use role="alert"; information and tip variants use role="status". The default aria-live="polite" avoids interrupting current screen-reader speech.
  • Set politeness="assertive" only for critical, time-sensitive messages. For a message that requires action, place it near the related content and move focus to the alert through its ref when appropriate.
  • Choose headerLevel to keep the title in the page’s logical heading hierarchy.
  • Provide a localized dismissLabel, handle onDismiss, and offer dismissal only when the message can safely be removed.
  • Set aria-atomic="true" when assistive technology should announce the entire message after an update.

API

These are the component-specific props. GlAlert, GlAlertDescription, and GlAlertActions also forward supported div attributes and refs.

GlAlert

Prop Description Default
variant Sets the semantic style to danger, warning, success, info, or tip. "info"
title Adds a short heading before the alert content.
headerLevel Sets the title heading level from 1 through 6. 2
dismissible Shows the dismiss button; visibility remains controlled by the parent. true
dismissLabel Sets the dismiss button’s accessible label. "Dismiss"
onDismiss Runs when the dismiss button is activated.
politeness Sets aria-live to polite, assertive, or off. "polite"
sticky Keeps the alert at the top of its scrolling container. Use only one sticky alert at a time. false
children Alert content, normally composed with the description and actions helpers.

GlAlertDescription

Provides the standard message layout and accepts children plus supported div attributes.

GlAlertActions

Lays out custom action controls and accepts children plus supported div attributes.