Alerts are banners that communicate a message with a severity attached to it. They grab the user’s attention to provide critical information needed in context.

Two Main Types

Standard Alerts

Standard alerts are used in the context of an application either in the content area itself or within components.


There are four different sub-types of standard alerts success, info, warning, and error.

App-Level Alerts

App-level alerts are used in the global context of an application. They are placed at the very top of all content and navigation.

There are three different sub-types of app-level alerts info, warning, and error.

Standard Alerts

Four different sub-types

There are four different sub-types of standard alerts: error, warning, info, and success.

Error

Reserved for errors, malfunctions, as well as critical issues like license expiration.

Warning

Reserved for warnings: a message that needs the user attention and aknowledgment but might not cause errors.

Info

Provides info to users in context. Shouldn’t be overused to replace regular content.

Success

Reserved to provide to a static persistent success message.

Order in context

Standard alerts convey different levels of severity and urgency. They’re ordered by the urgency in which the user needs to pay attention to: error, warning, info, then success.

In the case there are multiple of each sub-type, all of them are shown before another sub-type is reached. For example, multiple errors are shown before the first warning is.

Style

The consistency in the style of the standard alerts allows users to quickly identify them, pay attention to them, and acknowledge them.

Typography

Depending on the sub-type of a standard alert, make sure to communicate a clear, concise, and actionable message.

Size

There are two sizes of standard alerts: default and compact. Use the compact alert only in places where vertical space is scarce and information density is needed. Cards provide a good example here.

Placement

Standard alerts could be placed in multiple different contexts including inside of components.

Modals

Alerts could appear within modals. It is recommended that no more than one alert appear within a modal. Their function should not be to validate, validation should be done inline and closer to the error itself.

 

Cards

It is recommended to use concise language as you share an alert within a card. It is also recommended to use a compact-size alert. The focus of the alert should be on its content not on the alert appearing in it.

It is also recommended to have an alert at the very top of a card, on top of its title. An alert is meant to attract the attention of the user.

Using more than one alert within a card distracts the user and dilutes the importance of the alerts displayed.

Memory
10.05 GB free
1.94 GB used | 11.99 GB total

App-Level Alerts

Three different subtypes

There are three sub-types of app-level alerts: error, warning, and info.

Why no success app-level alert?

App-level alerts are global in nature. Reporting a success of an operation should either be communicated within context or as a notification message.

Order in context

App-level alerts follow the same urgency order as standard alerts: error, warning, and info.

Placement

App-level alerts are placed at the very top of the global context. They should not be placed in any other configuration. Their purpose is to provide global alerts available and relating to the full context of the overall application.

App-level alerts appear at the very top of your application

Code & Examples

Several classes and elements are required to implement the Clarity alert layout. A table of these classes and elements with a brief description of each follows:

.alertThis class is a wrapper around .alert-items and the .close button. Place the .close button before the alert items.
.alert-itemsThis class is a wrapper around one or more .alert-item elements.
.alert-itemThis class is a wrapper around .alert-text, .alert-icon-wrapper, and .alert-actions.
.alert-icon-wrapper.alert-icon-wrapper contains a clr-icon with the classname .alert-icon applied to it. The icons used for the different alert types of success, danger, warning, and info are, respectively: check-circle, exclamation-circle, exclamation-triangle, and info-circle.
.alert-actions.alert-actions can consist of dropdowns or links. Each action should extend the .alert-action class.

Types

Clarity has error, warning, information, and success alerts denoted by the following classes:

  • .alert-danger
  • .alert-warning
  • .alert-info
  • .alert-success
Header
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
<div class="alert alert-danger" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon>
            </div>
            <span class="alert-text">...</span>
            <div class="alert-actions">
                <div class="alert-action dropdown bottom-right">
                    <button class="dropdown-toggle">
                        Actions
                        <clr-icon shape="caret down"></clr-icon>
                    </button>
                    <div class="dropdown-menu">
                        <a class="dropdown-item" href="...">Shutdown</a>
                        <a class="dropdown-item" href="...">Suspend</a>
                        <a class="dropdown-item" href="...">Reboot</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon>
            </div>
            <span class="alert-text">...</span>
            <div class="alert-actions">
                <div class="alert-action dropdown bottom-right">
                    <button class="dropdown-toggle">
                        Actions
                        <clr-icon shape="caret down"></clr-icon>
                    </button>
                    <div class="dropdown-menu">
                        <a class="dropdown-item" href="...">Shutdown</a>
                        <a class="dropdown-item" href="...">Suspend</a>
                        <a class="dropdown-item" href="...">Reboot</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="alert alert-warning" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="exclamation-triangle"></clr-icon>
            </div>
            <span class="alert-text">...</span>
            <div class="alert-actions">
                <div class="alert-action dropdown bottom-right open">
                    <button class="dropdown-toggle">
                        Actions
                        <clr-icon shape="caret down"></clr-icon>
                    </button>
                    <div class="dropdown-menu">
                        <a class="dropdown-item" href="...">Shutdown</a>
                        <a class="dropdown-item" href="...">Suspend</a>
                        <a class="dropdown-item" href="...">Reboot</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>
<div class="alert alert-info" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="info-circle"></clr-icon>
            </div>
            <span class="alert-text">...</span>
            <div class="alert-actions">
                <a href="..." class="alert-action">Acknowledge</a>
                <a href="..." class="alert-action">Reset to green</a>
            </div>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>
<div class="alert alert-success" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="check-circle"></clr-icon>
            </div>
            <span class="alert-text">...</span>
        </div>
    </div>
</div>

Placement

Alerts in the Content Area
Header
This alert is at the top of the page.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

This alert is in the middle of the page.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<div class="content-area">
    <div class="alert alert-danger" role="alert">
        <div class="alert-items">
            <div class="alert-item static">
                <div class="alert-icon-wrapper">
                    <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon>
                </div>
                <span class="alert-text">
                    This alert is at the top of the page.
                </span>
            </div>
        </div>
    </div>
    <p>...</p>
    <div class="alert alert-success" role="alert">
        <div class="alert-items">
            <div class="alert-item static">
                <div class="alert-icon-wrapper">
                    <clr-icon class="alert-icon" shape="check-circle"></clr-icon>
                </div>
                <span class="alert-text">
                    This alert is in the middle of the page.
                </span>
            </div>
        </div>
    </div>
    <p>...</p>
</div>
Alerts in Cards
Use small alerts in a card.
Project BOwner: Jane Doe

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

<div class="card">
    <div class="card-block">
        <div class="alert alert-warning alert-sm" role="alert">
            <div class="alert-items">
                <div class="alert-item static">
                    <div class="alert-icon-wrapper">
                        <clr-icon class="alert-icon" shape="exclamation-triangle"></clr-icon>
                    </div>
                    <div class="alert-text">
                        Use small alerts in a card.
                    </div>
                </div>
            </div>
            <button type="button" class="close" aria-label="Close">
                <clr-icon aria-hidden="true" shape="close"></clr-icon>
            </button>
        </div>
        <div class="card-media-block wrap">
            <img class="card-media-image" src="//placehold.it/60x60" />
            <div class="card-media-description">
                <span class="card-media-title">Project B</span>
                <span class="card-media-text">Owner: Jane Doe</span>
            </div>
        </div>
        <p class="card-text">...</p>
    </div>
    <div class="card-footer">
        <a class="card-link">Button One</a>
        <a class="card-link">Button Two</a>
    </div>
</div>
Alerts in Modals
<div class="modal static bump-down">
    <div class="modal-dialog" role="dialog" aria-hidden="true">
        <div class="modal-content">
            <div class="alert alert-danger" role="alert">
                <div class="alert-items">
                    <div class="alert-item static">
                        <div class="alert-icon-wrapper">
                            <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon>
                        </div>
                        <span class="alert-text">
                            Alert in a modal.
                        </span>
                    </div>
                </div>
            </div>
            <div class="modal-header">
                <button aria-label="Close" class="close" type="button">
                    <clr-icon aria-hidden="true" shape="close"></clr-icon>
                </button>
                <h3 class="modal-title">I have a nice title</h3>
            </div>
            <div class="modal-body">
                <p>But not much to say...</p>
            </div>
            <div class="modal-footer">
                <button class="btn btn-outline" type="button">Cancel</button>
                <button class="btn btn-primary" type="button">Ok</button>
            </div>
        </div>
    </div>
</div>

Size

Use the .alert-sm class with .alert for an alert 24 pixels in height. The default is 36 pixels.

Header
This is an alert with 36px height.
This is an alert with 24px height.
<div class="alert alert-danger">
    <div class="alert-items">
        <div class="alert-item static" role="alert">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon>
            </div>
            <span class="alert-text">
                This is an alert with 36px height.
            </span>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>
<div class="alert alert-success alert-sm" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="check-circle"></clr-icon>
            </div>
            <span class="alert-text">
                This is an alert with 24px height.
            </span>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>

App-Level Alerts

.alert-app-level

This class must be applied with .alert to render an app-level alert.

Alert Type: Danger
Alert Type: Warning
Alert Type: Info
<div class="alert alert-app-level alert-danger" style="margin-bottom:24px" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon>
            </div>
            <div class="alert-text">
                Alert Type: Danger
            </div>
            <div class="alert-actions">
                <button class="btn alert-action">Action</button>
            </div>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>
<div class="alert alert-app-level alert-warning" style="margin-bottom:24px" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="exclamation-triangle"></clr-icon>
            </div>
            <div class="alert-text">
                Alert Type: Warning
            </div>
            <div class="alert-actions">
                <button class="btn alert-action">Action</button>
            </div>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>
<div class="alert alert-app-level alert-info" role="alert">
    <div class="alert-items">
        <div class="alert-item static">
            <div class="alert-icon-wrapper">
                <clr-icon class="alert-icon" shape="info-circle"></clr-icon>
            </div>
            <div class="alert-text">
                Alert Type: Info
            </div>
            <div class="alert-actions">
                <button class="btn alert-action">Action</button>
            </div>
        </div>
    </div>
    <button type="button" class="close" aria-label="Close">
        <clr-icon aria-hidden="true" shape="close"></clr-icon>
    </button>
</div>

Examples

1. App-Level Alert in the main-container
A new update is now available. Upgrade to v.1234.
Header

Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.

<div class="main-container">
    <div class="alert alert-app-level alert-info" role="alert">
        <div class="alert-items">
            <div class="alert-item static">
                <div class="alert-icon-wrapper">
                    <clr-icon class="alert-icon" shape="info-circle"></clr-icon>
                </div>
                <div class="alert-text">
                    A new update is now available. Upgrade to v.1234.
                </div>
                <div class="alert-actions">
                    <button class="btn alert-action">Install Update</button>
                </div>
            </div>
        </div>
        <button type="button" class="close" aria-label="Close">
            <clr-icon aria-hidden="true" shape="close"></clr-icon>
        </button>
    </div>
    <header class="header header-6">
        <div class="branding">
            <span class="title">Header</span>
        </div>
    </header>
    <div class="content-container">
        <div class="content-area">
            <p>...</p>
        </div>
    </div>
</div>
2. Custom Icon in an App-Level Alert
A new update is now available. Upgrade to v.1234.
Header

Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.

<div class="main-container">
    <div class="alert alert-app-level alert-warning" role="alert">
        <div class="alert-items">
            <div class="alert-item static">
                <div class="alert-icon-wrapper">
                    <clr-icon class="alert-icon" shape="download"></clr-icon>
                </div>
                <div class="alert-text">
                    A new update is now available. Upgrade to v.1234.
                </div>
                <div class="alert-actions">
                    <button class="btn alert-action">Install Update</button>
                </div>
            </div>
        </div>
        <button type="button" class="close" aria-label="Close">
            <clr-icon aria-hidden="true" shape="close"></clr-icon>
        </button>
    </div>
    <header class="header header-6">
        <div class="branding">
            <span class="title">Header</span>
        </div>
    </header>
    <div class="content-container">
        <div class="content-area">
            <p>...</p>
        </div>
    </div>
</div>

Angular Component

Summary of Options

InputValuesDefaultEffect
[clrAlertClosable]
Type: Boolean
Default: true
true, falsetrueIf false, the alert will not be closable by clicking on the top-right "x".
[(clrAlertClosed)]
Type: Boolean
Default: false
true, falsefalse Two-way binding on the state of the alert: opened or closed.
[clrAlertType]
Type: String
Default:
"info"
"info", "warning", "success" and "danger""info"Sets the type of the alert.
[clrAlertSizeSmall]
Type: Boolean
Default: false
true, falsefalseIf true, renders a small alert.
[clrAlertIcon]
Type: String
Default: varies
icon name as stringvariesView supported icons.
[clrAlertAppLevel]
Type: Boolean
Default: false
true, falsefalseIf true, renders an app-level alert.
Examples
1. clrAlertClosable set to false. Default value is true.
Header

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<clr-alert [clrAlertClosable]="false">
    <clr-alert-item>
        <span class="alert-text">
            This alert cannot be dismissed.
        </span>
        <div class="alert-actions">
            <clr-dropdown>
                <button class="dropdown-toggle" clrDropdownTrigger>
                    Actions
                    <clr-icon shape="caret down"></clr-icon>
                </button>
                <clr-dropdown-menu clrPosition="bottom-right">
                    <a href="..." class="dropdown-item" clrDropdownItem>Shutdown</a>
                    <a href="..." class="dropdown-item" clrDropdownItem>Delete</a>
                    <a href="..." class="dropdown-item" clrDropdownItem>Reboot</a>
                </clr-dropdown-menu>
            </clr-dropdown>
        </div>
    </clr-alert-item>
</clr-alert>
<clr-alert [clrAlertType]="'warning'">
    <clr-alert-item>
        <span class="alert-text">
            Try closing this alert.
        </span>
    </clr-alert-item>
</clr-alert>
2. clrAlertType set to alert-success. Default value is alert-info. Accepts values same as the static alert type classes.
Header

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<clr-alert [clrAlertType]="'success'">
    <clr-alert-item>
        <span class="alert-text">
            This alert indicates success.
        </span>
    </clr-alert-item>
</clr-alert>
<clr-alert>
    <clr-alert-item>
        <span class="alert-text">
            This is a default info alert.
        </span>
    </clr-alert-item>
</clr-alert>
3. clrAlertSizeSmall set to true. Default value is false.
Header

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<clr-alert [clrAlertSizeSmall]="true">
    <clr-alert-item>
        <span class="alert-text">
            This is a small alert.
        </span>
    </clr-alert-item>
</clr-alert>
<clr-alert>
    <clr-alert-item>
        <span class="alert-text">
            This is a regular alert.
        </span>
    </clr-alert-item>
</clr-alert>
4. Binding to the clrAlertClosedChange event.
Header
<clr-alert [clrAlertType]="'success'" (clrAlertClosedChange)="onClose()">
    <clr-alert-item>
        <span class="alert-text">
            This alert indicates a success!
        </span>
    </clr-alert-item>
</clr-alert>
<div>{{closeMessage}}</div>
export class AlertAngularDemo  {
    closeMessage: string = "";

    onClose() {
        this.closeMessage = "The alert has been closed";
    }
}
5. clrAlertAppLevel set to true. Default is false.
Header

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus non beatae omnis esse quibusdam dolorum voluptatem reiciendis quaerat assumenda optio, porro expedita similique dolore quidem aliquam. Ullam, eaque enim nobis.

<clr-alert [clrAlertType]="'danger'" [clrAlertAppLevel]="true">
    <clr-alert-item>
        <span class="alert-text">
            This is an app level alert.
        </span>
        <div class="alert-actions">
            <button class="btn alert-action">Fix</button>
        </div>
    </clr-alert-item>
</clr-alert>
6. Multiple app level alerts can be displayed with previous and next buttons.
1 / 3
Header

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus non beatae omnis esse quibusdam dolorum voluptatem reiciendis quaerat assumenda optio, porro expedita similique dolore quidem aliquam. Ullam, eaque enim nobis.


    <clr-alerts>
        <clr-alert [clrAlertType]="'info'" [clrAlertAppLevel]="true">
            <clr-alert-item>
            <span class="alert-text">
                This is the first app level alert.
            </span>
            <div class="alert-actions">
                <button class="btn alert-action">Fix</button>
            </div>
        </clr-alert-item>
        </clr-alert>
        <clr-alert [clrAlertType]="'danger'" [clrAlertAppLevel]="true">
            <clr-alert-item>
            <span class="alert-text">
                This is a second app level alert.
            </span>
            <div class="alert-actions">
                <button class="btn alert-action">Fix</button>
            </div>
        </clr-alert-item>
    </clr-alert>
</clr-alerts>