From 3373d0c615cfce3936a3219fca178c3bfdc0b621 Mon Sep 17 00:00:00 2001 From: Mike Perrotti Date: Fri, 1 Dec 2023 14:06:11 -0500 Subject: [PATCH] adds button loading state guidelines (#686) --- content/components/button.mdx | 54 +++++++++++++++++++++++++++++++++ content/ui-patterns/loading.mdx | 37 ++-------------------- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/content/components/button.mdx b/content/components/button.mdx index c5173d845..faca33de1 100644 --- a/content/components/button.mdx +++ b/content/components/button.mdx @@ -290,6 +290,31 @@ There are two recommended ways an inactive button should respond to user input: +### Loading + + + +An button that looks disabled, but the text is replaced with a spinning loading indicator + +
+ +You may use a button loading state if we need to wait for a button's action to be completed. Refer to the accessibility section's [button loading state](#button-loading-state) guidance for more information. + +
+ +
+ ## Best practices ### Primary and outline button usage @@ -417,6 +442,35 @@ Labeling buttons properly lets users know what will happen when they activate th Read more about [descriptive buttons](/guides/accessibility/descriptive-buttons). +### Button loading state + +A button in a loading state with a11y annotations + + + + + +When implementing a "loading" button state, don't remove the button from the DOM or pass the `disabled` attribute. Doing so would make it impossible to tab to the button. If the button was just focused and activated, it would reset focus. Resetting focus would disrupt the keyboard navigation flow, and creates a confusing experience for assistive technologies such as screen readers. + +Once the button is activated (and is in a loading state), it get the attribute `aria-disabled="true"`. + +A separate, visually hidden element should be rendered outside of the `