Thread Reader
Wes Bos

Wes Bos
@wesbos

Dec 11, 2024
2 tweets
Tweet

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

Help me, you're my only hope I have a button that should display a loading spinner, usually with a different width than the content. but how do I prevent the button from resizing when it does? - I do not want to set fixed pixel width on all buttons - I need a tailwind or react solution
If you like this one, here is another demo of CSS Grid stacking → x.com/wesbos/status/
Wes Bos

Wes Bos
@wesbos

Are you using position: absolute; to overlap elements? It's almost always better to Use CSS Grid instead!
Wes Bos

Wes Bos

@wesbos
Fullstack JS Dev ❯ https://t.co/6heZ7gZqg1 ❯ https://t.co/lOo3xh23G1 ❯ https://t.co/XYbxq79WBS ❯ Posts 🔥 Tips ❯ Co-hosts @SyntaxFM
Follow on 𝕏
Missing some tweets in this thread? Or failed to load images or videos? You can try to .