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. <a href="/">Donec</a> 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. <a href=\"/\">Donec</a> laoreet, urna sit amet convallis rhoncus, felis ex pellentesque neque, nec ultrices dui enim ut diam.",
"modifier": "success"
}
.field-message {
@include theme('color', 'color-zero', 'message-text-color');
@include theme('background-color', 'color-info-light', 'info-message-background');
@include theme('border-color', 'color-info', 'info-message-icon-color');
$field-message-icon-size: 30px;
$field-message-icon-margin: 30px;
display: inline-block;
position: relative;
align-items: center;
max-width: 800px;
min-height: 50px;
margin-top: 4px;
padding: 34px 24px 14px;
border-bottom: 3px solid;
:nth-last-child(2) {
margin-bottom: 0;
}
&::before {
display: block;
position: absolute;
top: 30px;
left: 14px;
width: $field-message-icon-size;
height: $field-message-icon-size;
margin: auto $field-message-icon-margin auto auto;
font-size: 1.3rem;
line-height: $field-message-icon-size;
text-align: center;
}
&,
& * {
font-size: .7rem;
}
.accolade {
top: 0;
transform: rotate(180deg);
&::before {
left: -1px;
width: calc(100% - 30px + 1px);
}
&::after {
right: -1px;
width: 31px;
}
}
a {
@include theme('color', 'color-zero', 'field-messages-color');
@include link-background('color-zero', 'link-hover-background');
}
&.success {
@include icon('checkmark-circle');
@include theme('background-color', 'color-success-light', 'success-message-background');
@include theme('border-color', 'color-success', 'success-message-icon-color');
padding-left: 58px;
&::before {
@include theme('color', 'color-success', 'success-message-icon-color');
}
a {
@include link-background('color-zero', 'color-success-light--darken-1', 'success-message-link-border-color', 'success-message-link-background');
}
}
&.error {
@include icon('cross-circle');
@include theme('background-color', 'color-error-light', 'error-message-background');
@include theme('border-color', 'color-error', 'error-message-icon-color');
padding-left: 58px;
&::before {
@include theme('color', 'color-error', 'error-message-icon-color');
}
a {
@include link-background('color-zero', 'color-error-light--darken-1', 'error-message-link-border-color', 'error-message-link-background');
}
}
}