Skip to main content

Async link

Usage

Overview

The AsyncLink component provides a way to navigate to a new page or route, but only after completing certain tasks or checks first. You can use it to control when and if the user is redirected based on specific conditions or operations.

When to use

Use the AsyncLink component for:

  • Checking user actions, such as making sure that a form is successfully submitted before moving to a new page.
  • Loading data, ensuring that important data for the next page is loaded before navigating.
  • Completing tasks like saving user actions, tracking user behavior, asking for user confirmation, or saving the current state before redirecting.

When not to use

Don't use the AsyncLink component for:

  • Immediate navigation. If immediate navigation is needed without any preconditions or checks, avoid using the async link. Instead, use the link component.
  • Simple navigation. If the navigation doesn't involve any asynchronous tasks, such as data loading or user actions, using an async link might introduce unnecessary complexity. Instead, use the link component.

Formatting

Anatomy

Image depicting the anatomy of the AsyncLink component

The AsyncLink component consists of the following elements:

  1. Label: Descriptive text that provides context and explains where the link leads to.

Content

The AsyncLink component follows the content guidelines for the link component.

Behaviors

AsyncLink displays a loading indicator while fetching content. It consists of 3 pulsating dots. The loading indicator ensures that users are aware of ongoing activity.

AsyncLink handles errors by presenting an error message or fallback UI when necessary. Upon successful completion, it updates to display the fetched content.

Accessibility

The contrast ratio of textual elements against their background is above 4.5:1 as per WCAG 2.1 AA requirements. Non-textual content that needs to convey meaning (such as icons and keyboard focus visibility) has a contrast ratio of at least 3:1 with its adjacent colors. All content is visible and functional up to and including 400% without requiring scrolling in two dimensions.

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. However, changes made by the content author can affect accessibility conformance.

Follow the guidance below when using this component in your applications:

  • Ensure that any color changes meet the required threshold of 4.5:1.
  • Ensure screen readers convey the loading state and any error messages.
  • Avoid using words and phrases such as “Click here” or “here” as link text. Instead, create meaningful link text that makes sense on its own.