Quick facts
What this addon covers
- Import path
a11y-async-button/addons/status- Pattern
- Visible status connector for one async button
- Status target
- Existing element chosen by selector, description, or parent markup
- Runtime deps
- None beyond the core package
Live demo
Sync button state to visible text
The addon does not create UI. Each button points at an existing status element and mirrors loading, success, error, and reset state changes into that element.
Save preferences
Ready to save preferences.
Send invite
Ready to send an invite.
Try it
Useful checks
- Activate Save preferences and watch the nearby status text move through loading and success.
- Change Simulated result to Error, then activate Send invite.
- Use Tab, Enter, and Space to confirm native button behavior.
- Use Reset to return the button and status text to their original idle state.
Example code
Import only the status addon
import { createAsyncButtonStatus } from "a11y-async-button/addons/status";
import "a11y-async-button/styles.css";
createAsyncButtonStatus(button, {
target: "#settings-status",
loadingStatusText: "Saving preferences...",
successStatusText: "Preferences saved.",
errorStatusText: "Preferences could not be saved.",
onAction: async () => {
await savePreferences();
}
});
Accessibility notes
What changes for users
Keyboard and focus
- The addon keeps native button activation for Enter and Space.
- Focus stays on the button while the visible status updates.
- Repeated activation is still controlled by the core async button behavior.
Status output
- The status element receives
role="status",aria-live="polite", andaria-atomic="true"when missing. - Custom status text can come from options or data attributes.
- The addon restores the status element's original text and attributes on destroy.