ActionSwap
A pill button that cycles through related states, like Pin and Pinned, with width, tone, icon and label morphing together.
Examples
The first press fails and the second succeeds, so you can see both paths.
Current value: dynamic
When to use ActionSwap
Use when
Use ActionSwap for a single control that cycles through a short list of related states: pin and unpin, compile and compiled, dynamic, gradual and static typing.
Avoid when
Avoid it for a one-off save, where a Button with a loading state is enough, and for choosing between many options, where a Select or Tabs fit better.
Accessibility
It is a native button. Its accessible name is the visible label (the state's label while it is working), Enter and Space advance the state, and a polite live region announces each new label and any failure. While an action is pending it sets aria-busy and aria-disabled.