Error alert
Used at the top of the page, to summarise a unsuccessful user action.
How it looks (preview) (preview all)
How to call this component
<%= render "govuk_publishing_components/components/error_alert", {
message: "Message to alert the user to a unsuccessful action goes here"
} %>
Accessibility acceptance criteria
- should be focused on page load, to ensure the message is noticed by assistive tech
- Should have a role of
alert
to communicate that is a important and time sensitive message
Other examples
Standard options
This component uses the component wrapper helper. It accepts the following options and applies them to the parent element of the component. See the component wrapper helper documentation for more detail.
id
- accepts a string for the element ID attributedata_attributes
- accepts a hash of data attributesaria
- accepts a hash of aria attributesclasses
- accepts a space separated string of classes, these should not be used for styling and must be prefixed withjs-
margin_bottom
- accepts a number from0
to9
(0px
to60px
) using the GOV.UK Frontend spacing scale (defaults to no margin)role
- accepts a space separated string of roleslang
- accepts a language attribute valueopen
- accepts an open attribute value (true or false)hidden
- accepts an empty string, ‘hidden’, or ‘until-found’tabindex
- accepts an integer. The integer can also be passed as a string.dir
- accepts ‘rtl’, ‘ltr’, or ‘auto’.
With message and description (preview)
Message to alert the user to a unsuccessful action goes here
A further description
<%= render "govuk_publishing_components/components/error_alert", {
message: "Message to alert the user to a unsuccessful action goes here",
description: "A further description"
} %>
Long example (preview)
<%= render "govuk_publishing_components/components/error_alert", {
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut aliquet
dignissim dui, ac laoreet tortor vulputate nec. Aenean quis turpis
orci. Proin semper porttitor ipsum, vel maximus justo rutrum vel.
Morbi volutpat facilisis libero. Donec posuere eget odio non egestas.
Nullam sed neque quis turpis.
"
} %>
With data attributes (preview)
The example shown applies a tracking attribute specifically for use by Google Tag Manager in Content Publisher.
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the GA4 link tracker.
Message to alert the user to a unsuccessful action goes here
A further description
<%= render "govuk_publishing_components/components/error_alert", {
message: "Message to alert the user to a unsuccessful action goes here",
description: "A further description",
data_attributes: {
tracking: "GTM-123AB"
}
} %>
With specified id attribute (preview)
<%= render "govuk_publishing_components/components/error_alert", {
id: "test-id",
message: "Message to alert the user to a unsuccessful action goes here"
} %>