A field message is used in the context of a form to provide help or feedback on fields or fieldsets.
A field message should not be used outside the context of a form.
There are three types of field messages:
A normal field message is used to provide help on a field or fieldset.
An error field message is used to provide feedback on a field or fieldset. It informs the user that there was an error in filling in the field or fieldset.
A success field message is used to inform the user that the field or fieldset is correctly filled in.
For more information about the usage of field messages components in the context of a form and form validation, see the form component documentation.
{% if field_message %}
<div class="field-message {{ modifier }}"
{% if modifier %}
role="alert"
{% endif %}
{% if id %}
id="{{ id }}"
{% endif %}>
{{ field_message }}
{% include '@accolade' %}
</div>
{% endif %}
<div class="field-message success" role="alert">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet, urna sit amet convallis rhoncus, felis ex pellentesque neque, nec ultrices dui enim ut diam.
<div class="accolade "></div>
</div>
{
"field_message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet, urna sit amet convallis rhoncus, felis ex pellentesque neque, nec ultrices dui enim ut diam.",
"modifier": "success"
}
.field-message {
@include theme('color', 'color-tertiary--lighten-1', 'field-messages-color');
$field-message-icon-size: 1.5rem;
$field-message-icon-margin: 1.5rem;
display: inline-block;
position: relative;
align-items: center;
max-width: 40rem;
min-height: 2.5rem;
padding: 1.7rem 1.2rem .7rem;
border-radius: border-radius('radius-1');
background-color: color('cyan', -5);
font-size: .8rem;
overflow: hidden;
&::before {
display: block;
position: absolute;
top: 1.5rem;
left: .7rem;
width: $field-message-icon-size;
height: $field-message-icon-size;
margin: auto $field-message-icon-margin auto auto;
border-radius: 100%;
background-color: color('white');
font-size: 1.1rem;
line-height: $field-message-icon-size;
text-align: center;
}
.accolade {
top: 0;
transform: rotate(180deg);
&::before {
left: -1px;
width: calc(100% - 1.5rem + 1px);
}
&::after {
right: -1px;
width: calc(1.5rem + 1px);
}
}
a {
@include theme('color', 'color-tertiary--lighten-1', 'field-messages-color');
@include link-background('color-tertiary', 'color-primary--lighten-3', 'field-messages-link-border-color', 'link-background-color');
&:hover {
@include theme('color', 'color-tertiary', 'field-messages-link-hover-color');
}
}
&.success {
@include icon('checkmark');
@include theme('background-color', 'color-success--lighten-4', 'field-description-background');
padding-left: 2.9rem;
&::before {
@include theme('color', 'color-success', 'field-description-icon');
}
a {
@include link-background('color-tertiary', 'color-success--lighten-3', 'field-messages-link-border-color', 'field-messages-success-background-color');
}
}
&.error {
@include icon('cross');
@include theme('background-color', 'color-error--lighten-4', 'field-description-background');
padding-left: 2.9rem;
&::before {
@include theme('color', 'color-error', 'field-description-icon');
}
a {
@include link-background('color-tertiary', 'color-error--lighten-3', 'field-messages-link-border-color', 'field-messages-error-background-color');
}
}
}