packages/components/eui-alert/eui-alert.component.ts
Alert component for displaying short, important messages that attract user attention without interrupting tasks. Provides semantic variants (success, info, warning, danger) with corresponding visual styling and icons. Supports optional title section, close button, and keyboard focus for accessibility. Visibility can be controlled programmatically or by user dismissal via close button. Includes ARIA attributes for screen reader support and unique ID generation for content association.
Supports four semantic variants: success, info, warning, and danger (via BaseStatesDirective)
Optional title section via <eui-alert-title> content projection
Main content area for alert message (projected via ng-content)
Optional close button when isCloseable is true
Icon state indicator matching the alert variant
Closeable: Can be dismissed by user via close button
Focusable: Can receive keyboard focus for accessibility
Visibility control: Can be shown/hidden via isVisible model
Accessibility: Includes ARIA attributes (role="alert", aria-describedby)
Unique ID generation for content association
<eui-alert>
Important message for the user
</eui-alert><eui-alert euiSuccess>
<eui-alert-title>Success</eui-alert-title>
Your changes have been saved successfully.
</eui-alert><eui-alert euiWarning [isCloseable]="true" [(isVisible)]="showAlert" (closeAlert)="onClose()">
This is a dismissible warning message.
</eui-alert><eui-alert euiDanger [isFocusable]="true">
Critical error that requires attention.
</eui-alert>
| changeDetection | ChangeDetectionStrategy.OnPush |
| HostDirectives |
BaseStatesDirective
Inputs : euiSuccess euiInfo euiWarning euiDanger euiVariant
|
| selector | div[euiAlert], eui-alert |
| imports |
NgTemplateOutlet
EUI_ICON_BUTTON
EUI_ICON_STATE
|
| templateUrl | ./eui-alert.component.html |
| styleUrl | ./eui-alert.scss |
Properties |
Methods |
Inputs |
Outputs |
HostBindings |
Accessors |
| e2eAttr |
Default value : 'eui-alert'
|
|
Data attribute value for end-to-end testing identification. Applied as data-e2e attribute on the host element. |
| isFocusable |
Default value : false, { transform: booleanAttribute }
|
|
Makes the alert focusable via keyboard navigation. When true, sets tabindex to 0 enabling keyboard focus for accessibility. |
| isVisible |
Default value : true
|
|
Controls the visibility state of the alert. Two-way bindable model that can be programmatically controlled or updated by user dismissal. |
| closeAlert |
Type : boolean
|
|
Emitted when the alert is closed via the close button. Payload: boolean - always emits false to indicate alert is hidden Triggered when user clicks the close button (when isCloseable is true). |
| isVisible |
|
Controls the visibility state of the alert. Two-way bindable model that can be programmatically controlled or updated by user dismissal. |
| attr.aria-describedby |
Type : string
|
|
Sets the |
| attr.data-e2e |
Type : string
|
|
Sets the |
| attr.role |
Type : string
|
Default value : 'alert'
|
|
Sets the |
| attr.tabindex |
Type : string
|
|
Sets the |
| class |
Type : string
|
|
Computes and returns the CSS classes for the component based on its current state. |
| onCloseClick |
onCloseClick()
|
|
Hide the alert and emits the
Returns :
void
|
| alertTitle |
Type : QueryList<EuiAlertTitleComponent>
|
Decorators :
@ContentChild(undefined, {static: false})
|
|
Content for the alert title given by |
| baseStatesDirective |
Type : unknown
|
Default value : inject(BaseStatesDirective)
|
| role |
Type : string
|
Default value : 'alert'
|
Decorators :
@HostBinding('attr.role')
|
|
Sets the |
| cssClasses |
getcssClasses()
|
|
Computes and returns the CSS classes for the component based on its current state.
Returns :
string
|
| ariaDescribedBy |
getariaDescribedBy()
|
|
Sets the
Returns :
string
|
| tabindex |
gettabindex()
|
|
Sets the
Returns :
string
|
| e2eAttribute |
gete2eAttribute()
|
|
Sets the
Returns :
string
|