How do you make a button that doesn't change it's width when it's in a loading state?
Use CSS Grid to stack items, and visibility: hidden to hide/show spinner!
This approach allows the largest item to size the button, and keeps the button text accessible
I absolutely position my spinner in the center of the button and then set the text to opacity: 0. No layout shift. Been doing that before Grid was even a thing.
I see what you’re getting at. I’ve never really worried about updating the text to “Saving…” but that makes sense.
I’m no accessibility expert, happy to learn another nugget.
Re: accessibility: while this is ok, it's generally better to use actual text (probably a `.sr-only` span) than `aria-label`. Text is more easily picked up by ATs universally, and can also be translated to other languages more easily than HTML attributes. Plus: don't use ARIA if you don't have to.