Components · Actions · Action Swap
Back to Action SwapAction SwapNew
Use for one control that cycles through related states - Follow/Following, Send/Sent - with a working phase and in-place failure.
Properties
Size, corner radius and the content options below are properties of the same component, not separate elements - change them to check this component's appearances and states in the Live Preview.
Live Preview
Every appearance side by side, each in every state. One full matrix is rendered per selected Size and Corner radius combination.
When to use
One control that cycles through related states.
Component Guide
Overview
Action Swap swaps an action label while preserving its place and intent. Each press runs the async action, shows a working phase, then commits to the next state or shows a failure message.
When to Use
- One control that cycles through related states.
- Toggles that run async work and need a working phase.
- Short confirmations that revert on their own.
When Not to Use
- A single save with a success tick - use a plain Button.
- A label that never changes - use Button.
- A light/dark toggle - use Switch.
Best Practices
- Keep states few and labels short and similar in length.
- Put the async work in the action and return its promise.
- Customise the failure label for the context.
Accessibility
- Native button whose label always matches what is visible.
- Working sets aria-busy and aria-disabled so focus stays put.
- A polite status announces each new label and failure.
Related Components
Button, Copy Button, Switch.
{
"component": "Action Swap",
"category": "Actions",
"summary": "Action Swap swaps an action label while preserving its place and intent. Each press runs the async action, shows a working phase, then commits to the next state or shows a failure message.",
"whenToUse": [
"One control that cycles through related states.",
"Toggles that run async work and need a working phase.",
"Short confirmations that revert on their own."
],
"whenNotToUse": [
"A single save with a success tick - use a plain Button.",
"A label that never changes - use Button.",
"A light/dark toggle - use Switch."
],
"bestPractices": [
"Keep states few and labels short and similar in length.",
"Put the async work in the action and return its promise.",
"Customise the failure label for the context."
],
"accessibility": [
"Native button whose label always matches what is visible.",
"Working sets aria-busy and aria-disabled so focus stays put.",
"A polite status announces each new label and failure."
],
"relatedComponents": [
"Button",
"Copy Button",
"Switch"
]
}