Menu

Our save buttons hold both labels in one grid cell, and the five rules behind every form that no longer moves
📰

Our save buttons hold both labels in one grid cell, and the five rules behind every form that no longer moves

DEV Community: css·Daniel Pertu·1 day ago
#kqDGeOfa
#devtocss#devto#dev#form#button
Long article (565 words) — no AI summary yet.
Reading 0:00
15s threshold

The most common reason a form feels cheap is that it moves. A button says "Save", you click it, it says "Saving..." and gets narrower, and the button next to it slides left. Here is the small set of rules that stopped that across every form in CogniPrep Assess.

The forms are live if you want to poke at them: request a demo and contact support both use them.

Hold both labels in one cell

The old pattern was {pending ? 'Saving' : 'Save changes'} . The button's width follows its text, so it changes on every click. The fix is to render both labels in the same grid cell and hide one with visibility , so the button always has the width of the longer label:

< span className = "grid justify-items-center" > < span className = { cn ( 'col-start-1 row-start-1' , pending && 'invisible' ) } > { children } </ span > < span className = { cn ( 'col-start-1 row-start-1' , !…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.