1. Component Guide
  2. Success alert
Component

Success alert

Used at the top of the page, to summarise a successful user action.

Search for usage of this component on GitHub.

How it looks (preview) (preview all)

How to call this component

<%= render "govuk_publishing_components/components/success_alert", {
  message: "Message to alert the user to a successful action goes here"
} %>

GOV.UK Design System

This component incorporates components from the GOV.UK Design System:

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

With message and description (preview)

Descriptions can be passed as plain text but it is strongly recommended that you pass these as html, cleaned using raw or sanitize.

<%= render "govuk_publishing_components/components/success_alert", {
  message: "Message to alert the user to a successful action goes here",
  description: sanitize("<p class=\"govuk-body\">A further description</p>")
} %>

With custom title (preview)

This is for the heading element at the head of the component (reading “Success” by default) where the id is used by an aria-labelledby on screen reader focus of the element.

Please ensure that this id is unique across the view you are building.

<%= render "govuk_publishing_components/components/success_alert", {
  message: "Message to alert the user to a successful action goes here",
  title_id: "my-custom-success-id"
} %>

Long example (preview)

<%= render "govuk_publishing_components/components/success_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 custom margin bottom (preview)

The component accepts a number for margin bottom from 0 to 9 (0px to 60px) using the GOV.UK Frontend spacing scale. The default margins for the component are inherited from the notification-banner styles defined in the Design System.

<%= render "govuk_publishing_components/components/success_alert", {
  message: "Message to alert the user to a successful action goes here",
  margin_bottom: 3
} %>