
A spinner button component is a button component that generates a spinner inside of a button to indicate that a process is running. At the end of the process, a check icon is generated to indicate that the process is complete.
*This feature may apply to situations where an action navigates to a new page but still requires time to process (i.e. logging in)
**For longer running processes, we recommend using a progress indicator or _circular progress indicator (not a currently existing component)_







x-small spinner: 13px by 13px, 1.5 border thickness




inverse spinner: full circle (white border, 15% opacity), 1/3 circle (#007CBB border)


Default state -> Loading state

Loading state -> Success state

Success state -> Default state

Related/Original Issues: #1139 and #463
This looks good, but is there an onFailure state? I didn't see any examples.
@joshjohnson72 Good question, for now I think it would be best to display errors outside of the button (in the form of an alert or even an inline form validation). The spinner would stop before it gets to the success state, and return back to the default state:

I agree that when you hit an error you need space to explain the error, and the button doesn't afford that. Only downside I see is that space has to be reserved for that possible error alert, or all the other elements will be shifted.
@joshjohnson72 Thanks for bringing that up, what I meant to convey wasn't an empty space reserved for an alert but rather the point that an alert would show up if there was an error. Correct me if I'm wrong, but alerts take up the entire width of the screen and should only shift elements down vertically:

From the Clarity site on Alerts: "Alerts could appear within modals. It is recommended that no more than one alert appear within modal. Their function should not ve to validate, validation should be done inline and closer to the error itself."
I would tend to agree that the inline action should have errors shown near to it.
@joshjohnson72 I believe that is referring to inline form validations like this:

Which would also work with these spinner buttons:

My example just happens to have a button called "Validate" but it isn't referring to the same type of validation in that context 😅
A couple of additional notes here:
• This component will take the place of our current "Loading Button". If at all possible, we should repurpose that directive so we can introduce this functionality without a breaking change.
• The screen-reader only labels should be projected content so that users can also i18n it.
• Moving from one state to another should be declarative on the user's part so that way they can have full control of the button's loading state.
Great job, @gracesnoh ! Thanks for putting this together.
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.
Most helpful comment
I agree that when you hit an error you need space to explain the error, and the button doesn't afford that. Only downside I see is that space has to be reserved for that possible error alert, or all the other elements will be shifted.