Skip to content
Versions v4 v3 v2 v1

Alert

An alert is a notification that provides brief information to the user without blocking their workflow.

Overview

Installation

npm install @patternfly/elements

Usage

Slots

icon
title
Default Slot
actions

Attributes

variant

PatternFly supports several alert variants for different scenarios. Each variant has an associated status icon, background, and alert title coded to communicate the severity of an alert. Use the variant property to apply the following styling options. If no variant is specified, then the variant will be set to "default".

  • Default - Use for generic messages with no associated severity
  • Info - Use for general informational messages
  • Success - Use to indicate that a task or process has been completed successfully
  • Warning - Use to indicate that a non-critical error has occurred
  • Danger - Use to indicate that a critical or blocking error has occurred
DOM Property
variant
Type
| 'warning'
    | 'custom'
    | 'neutral'
    | 'info'
    | 'success'
    | 'danger'
Default
'neutral'
icon

Use the icon attribute to replace a default alert icon with a custom icon. The icon attribute is overridden by the icon slot.

DOM Property
icon
Type
string
Default
unknown
title-text

The title of the alert. Overridden by the title slot.

DOM Property
titleText
Type
string
Default
unknown
title-level

The heading level of the alert's title. Overridden by the title slot. Default: 3

DOM Property
titleLevel
Type
1 | 2 | 3 | 4 | 5 | 6
Default
unknown
inline

Use inline alerts to display an alert inline with content. All alert variants may use the inline attribute to position alerts in content-heavy areas, such as within forms, wizards, or drawers.

DOM Property
inline
Type
boolean
Default
false
plain

Use the plain attribute to make any inline alert plain. Plain styling removes the colored background but keeps colored text and icons.

DOM Property
plain
Type
boolean
Default
false
expandable

An alert can contain additional, hidden information that is made visible when users click a caret icon. This information can be expanded and collapsed each time the icon is clicked.

It is not recommended to use an expandable alert with a timeout in a toast alert group because the alert could timeout before users have time to interact with and view the entire alert.

See the toast alert considerations section of the alert accessibility documentation to understand the accessibility risks associated with using toast alerts.

DOM Property
expandable
Type
boolean
Default
false
expanded

True when an expandable alert is expanded

DOM Property
expanded
Type
boolean
Default
false
dismissable

When true, the alert displays a close button Clicking the close button removes the alert

DOM Property
dismissable
Type
boolean
Default
false

Methods

None

Events

close

When an alert is closed e.g. when close button is clicked or when the alert times out. Cancel the event to prevent the alert from being removed.

Event Type:
unknown

CSS Custom Properties

CSS Property Description Default
--pf-global--BoxShadow--lg 0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08)
--pf-global--BackgroundColor--100 #fff
--pf-global--BorderWidth--md 2px
--pf-global--FontSize--sm 0.875rem
--pf-global--Transition all 250ms cubic-bezier(0.42, 0, 0.58, 1)
--pf-global--default-color--200 #009596
--pf-global--icon--FontSize--md 1.125rem
--pf-global--FontWeight--bold 700
--pf-global--default-color--300 #003737
--pf-global--spacer--form-element 0.375rem
--pf-global--spacer--sm 0.5rem
--pf-global--spacer--xs 0.25rem
--pf-global--spacer--md 1rem
--pf-global--spacer--lg 1.5rem
--pf-global--success-color--100 #3e8635
--pf-global--success-color--200 #1e4f18
--pf-global--danger-color--100 #c9190b
--pf-global--danger-color--200 #a30000
--pf-global--warning-color--100 #f0ab00
--pf-global--warning-color--200 #795600
--pf-global--info-color--100 #2b9af3
--pf-global--info-color--200 #002952
--pf-global--palette--cyan-50 #f2f9f9
--pf-global--palette--green-50 #f3faf2
--pf-global--palette--red-50 #faeae8
--pf-global--palette--gold-50 #fdf7e7
--pf-global--palette--blue-50 #e7f1fa
--pf-c-alert__action-group--PaddingTop-base
--pf-c-alert__description--action-group--PaddingTop-base
--pf-global--Color--100 #151515
--pf-c-alert--PaddingTop
--pf-c-alert--PaddingRight
--pf-c-alert--PaddingBottom
--pf-c-alert--PaddingLeft
--pf-c-alert__FontSize
--pf-c-alert--BackgroundColor
--pf-c-alert--GridTemplateAreas
--pf-c-alert--m-success--BorderTopColor
--pf-c-alert--m-success__icon--Color
--pf-c-alert--m-success__title--Color
--pf-c-alert--m-inline--m-success--BackgroundColor
--pf-c-alert--m-danger--BorderTopColor
--pf-c-alert--m-danger__icon--Color
--pf-c-alert--m-danger__title--Color
--pf-c-alert--m-inline--m-danger--BackgroundColor
--pf-c-alert--m-warning--BorderTopColor
--pf-c-alert--m-warning__icon--Color
--pf-c-alert--m-warning__title--Color
--pf-c-alert--m-inline--m-warning--BackgroundColor
--pf-c-alert--BorderTopColor var(--pf-c-alert--m-info--BorderTopColor)
--pf-c-alert--m-info--BorderTopColor
--pf-c-alert--m-info__icon--Color
--pf-c-alert--m-info__title--Color
--pf-c-alert--m-inline--m-info--BackgroundColor
--pf-c-alert--BoxShadow var(--pf-c-alert--m-inline--BoxShadow)
--pf-c-alert--m-inline--BoxShadow
--pf-c-alert--m-inline--BackgroundColor
--pf-c-alert--BorderTopWidth var(--pf-c-alert--m-inline--m-plain--BorderTopWidth)
--pf-c-alert--m-inline--m-plain--BorderTopWidth
--pf-c-alert--m-inline--m-plain--BackgroundColor
--pf-c-alert--m-inline--m-plain--PaddingTop
--pf-c-alert--m-inline--m-plain--PaddingRight
--pf-c-alert--m-inline--m-plain--PaddingBottom
--pf-c-alert--m-inline--m-plain--PaddingLeft
--pf-c-alert--GridTemplateColumns var(--pf-c-alert--m-expandable--GridTemplateColumns)
--pf-c-alert--m-expandable--GridTemplateColumns
--pf-c-alert--m-expandable--GridTemplateAreas
--pf-c-alert--m-expandable__description--action-group--PaddingTop
--pf-c-alert__toggle-icon--Rotate var(--pf-c-alert--m-expanded__toggle-icon--Rotate)
--pf-c-alert--m-expanded__toggle-icon--Rotate
--pf-c-alert--m-expanded__description--action-group--PaddingTop
--pf-c-alert__toggle--MarginTop
--pf-c-alert__toggle--MarginBottom
--pf-c-alert__toggle--MarginLeft
--pf-c-alert__icon--MarginTop
--pf-c-alert__icon--MarginRight
--pf-c-alert__icon--FontSize
--pf-c-alert__icon--Color
--pf-c-alert__title--FontWeight
--pf-c-alert__title--Color
--pf-c-alert__description--PaddingTop
--pf-c-alert__description--action-group--PaddingTop

CSS Shadow Parts

None

© 2018-2025 Red Hat, Inc. Deploys by Netlify