Inline Notice
Context-level notice of confirmation, information or attention.
Last updated
Context-level notice of confirmation, information or attention.
Last updated
A notification that appears next to an individual element or control.
In order of priority, from high to low, the status of an inline notice is classified as either:
attention
confirmation
information
Experience the pattern in action on our companion eBay MIND patterns examples website.
View a fully styled example on eBay Skin.
Avoid having more than one high-priority notice visible at any time.
Avoid rendering high-priority inline notices on the server. For better discoverability, use a page notice instead. If you cannot use a page notice, then focus must be set on the inline notice.
Avoid using progress bars and spinners in conjunction with client-side notice.
Displaying a notice for a success or confirmation may not always be necessary. In the absence of an error message, a user can imply success (opinionated).
Nested interactive elements (such as links) must be keyboard focusable.
Screen reader must not announce low-priority server-side notices.
Screen reader must announce client-side content changes to any type of notice.
Screen reader must announce client-side visibility change of a hidden notice.
If the notice is related to a control, the notice must be announced as the description of that control.
Our implementation follows the Progressive Enhancement strategy. We build in a layered fashion that allows everyone to access the basic content and functionality of a web page.
The three layers are:
Content (HTML)
Presentation (CSS)
Behaviour (JS)
For our first example, we are going to mock up an implementation based on a typical "Add to Cart" button you might find on any eCommerce site these days. This button will render a high-priority notice whenever an error occurs.
Let's make it work on the server first, without any JavaScript or client-side rendering.
Form
We'll need a form, a hidden form input, and a submit button:
Clicking this button will submit the form. When the page reloads the server will take care of rendering any applicable success or error message.
At this stage, without JavaScript, any error message should be a server-side page notice, not an inline notice. Refer to the page notice developer guide for details.
Landmark Region
For our client side enhancement, let's create our error message inside of a landmark region, with an initial state of hidden
. When the hidden state is removed, the region will be discoverable via a screen reader's list of landmarks.
Live Region
Of course, we do not want to have to rely on a user opening up their list of landmarks to discover if an action was successful or not! We want to announce any error immediately. We do so by adding a live region inside of our landmark region.
Button Description
If the user leaves the button, and then returns back to it, it would be nice to remind the user of any error message. This is achieved this with the aria-describedby
property.
You can style the button and inline notice according to your design system guide.
The goal of JavaScript is to:
Prevent the form submit action
Perform the service call using AJAX
Display the error message next to our button
Step 3 is of most interest to us. We must ensure the error message is accessible while the user remains on the button.
Display Message
Assuming there was an error, we update the hidden
state of the live region content.
When the hidden
state is removed, assistive technology detects a visibility change in the subtree of the live region, and the content will be announced.
Keyboard focus remains on the button. Do not set focus to the inline-notice! That would defeat the purpose of the live region.
For all notices. It creates a landmark region. All landmark regions should be labelled (e.g. "Confirmation", "Information", "Attention").
For high-priority notices rendered and updated on the client only. The alert must be nested inside of the landmark region element.
Always set keyboard focus on high priority notices rendered by the server and visible at page load time. Again, these situations should be rare. Use a page notice instead.