Use the status message to inform users, give feedback, give advice, help them or confirm an action or a status.
Status messages are mostly used in the context of a form as a feedback mechanism, but they can also be used outside the context of forms.
There are four types of status messages:
A normal status message is used to provide general information or help to the user. The message should have enough information to help the user understand the message, the purpose of the message and to be clear, but should be as short as possible.
A warning status message is used to show a warning to the user. The message should be clear and helpful. Give the user constructive advice on how to prevent problems.
An error status message is used to show an error to the user. The message should be clear and helpful. Give the user constructive advice on how to fix the problem. When used in the context of a form or a wizard, make it easy for users to correct the error by preserving as much of the content as possible.
A success status message is used to provide information about an action or a status that is positive, a success. The message should have enough information to help the user understand the message, the purpose of the message and to be clear, but should be as short as possible.
For more information about the usage of the status message component in the context of a form and form validation, see the form component documentation.
<div class="messages {{ modifier }}" role="alert" aria-atomic="true">
{% if modifier == 'messages--status' %}
<h2 class="visually-hidden">{{ 'Status' }}</h2>
{% endif %}
<i class="{{ icon }}" aria-hidden="true"></i>
<p>{{ text }}</p>
</div>
<div class="messages messages--warning" role="alert" aria-atomic="true">
<i class="icon-exclamation" aria-hidden="true"></i>
<p>Aliquam ullamcorper vehicula leo. Mauris mattis egestas hendrerit. Sed <a href="#">vitae aliquet mauris</a>. Morbi at erat sed mi mollis maximus at sit amet enim. Sed quis libero eu mauris eleifend accumsan vitae semper turpis. Vestibulum nisl ipsum, ullamcorper euismod ultrices nec, tempor sit amet urna. Pellentesque bibendum a mi commodo consectetur. Aliquam nec est tellus.</p>
</div>
{
"text": "Aliquam ullamcorper vehicula leo. Mauris mattis egestas hendrerit. Sed <a href=\"#\">vitae aliquet mauris</a>. Morbi at erat sed mi mollis maximus at sit amet enim. Sed quis libero eu mauris eleifend accumsan vitae semper turpis. Vestibulum nisl ipsum, ullamcorper euismod ultrices nec, tempor sit amet urna. Pellentesque bibendum a mi commodo consectetur. Aliquam nec est tellus.",
"modifier": "messages--warning",
"icon": "icon-exclamation"
}
%messages,
.messages {
@include theme('color', 'color-tertiary--lighten-1', 'status-messages-color');
$status-message-icon-size: 2.1rem;
display: flex;
position: relative;
flex-direction: column;
align-items: center;
max-width: 40rem;
margin-top: 1rem;
margin-right: 0;
margin-bottom: 1rem;
padding: 1rem 1.2rem;
border-radius: border-radius('radius-1');
font-size: .8rem;
text-align: center;
i {
display: block;
flex: 0 0 $status-message-icon-size;
width: $status-message-icon-size;
margin-right: 0;
margin-bottom: 1rem;
border-radius: 100%;
background-color: color('white');
font-size: 1.5rem;
line-height: $status-message-icon-size;
text-align: center;
@include phablet {
align-self: flex-start;
}
}
@include phablet {
flex-direction: row;
align-items: center;
text-align: initial;
i {
margin-right: 1.2rem;
margin-bottom: 0;
}
}
&.messages--status {
@include theme('background-color', 'color-success--lighten-4', 'status-messages-success-background-color');
i {
@include theme('color', 'color-success', 'status-messages-success-icon');
}
a {
@include link-background('color-tertiary', 'color-success--lighten-3', 'status-messages-link-border-color', 'status-messages-success-link-background-color');
}
}
&.messages--error {
@include theme('background-color', 'color-error--lighten-4', 'status-messages-error-background-color');
i {
@include theme('color', 'color-error', 'status-messages-error-icon');
}
a {
@include link-background('color-tertiary', 'color-error--lighten-3', 'status-messages-link-border-color', 'status-messages-error-link-background-color');
}
}
&.messages--warning {
@include theme('background-color', 'color-warning--lighten-4', 'status-messages-warning-background-color');
i {
@include theme('color', 'color-warning', 'status-messages-warning-icon');
}
a {
@include link-background('color-tertiary', 'color-warning--lighten-3', 'status-messages-link-border-color', 'status-messages-warning-link-background-color');
}
}
p {
margin: 0;
}
a {
@include theme('border-color', 'color-tertiary', 'status-messages-link-border-color');
@include theme('color', 'color-tertiary--lighten-1', 'status-messages-color');
&:hover {
@include theme('color', 'color-tertiary', 'status-messages-link-hover-color');
}
}
}