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
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
Comments
Codepen: https://codepen.io/AleksandrHovhannisyan/pen/BaZJoyK
I’d go one step further and use both opacity and visibility, as then you’re able to transition between the two for a nice fade effect.
Also, small perf hack, if you go from opacity: 0.001 -> 1 instead of 0 ->1, it can use GPU to render. (I stole that from GSAP years ago)
I recognize this is a web tip. Most people won’t have that constraint.
I’m no accessibility expert, happy to learn another nugget.
https://www.youtube.com/watch?v=8327_1PINWI
None of us knew this was possible
https://twitter.com/wesbos/status/1866895899554926912
https://www.linkedin.com/feed/update/urn:li:activity:7272663944106782720/
https://www.threads.net/@wesbos/post/DDck7SpKB88
https://www.reddit.com/r/css/comments/1hbyxc1/a_button_that_doesnt_change_width_when_showing_a/
https://www.tiktok.com/@wesbos/video/7447207307097787653
https://www.instagram.com/reel/DDckx3hR3xh/
Isn’t this the platform where we’re allowed to post links? I just wanna share what I made and I can’t upload it here
I ended up re-editing this one for YouTube landscape but it’s not always the case
I absolutely love to get into details on how things work. I learned a lot of front-end stuff from you and will continue to do so.