Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: CSS
csslayout-shiftuxstability
Reserve space for dynamic UI to prevent layout jump
When a count or badge appears/disappears, the surrounding layout shouldn't jump. Reserve consistent space so toggling content doesn't shift neighbours.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | {count > 0 && <span>{count}</span>} // width changes when it appears/disappears |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | <span className="min-w-[1.5rem] text-center">{count > 0 ? count : ''}</span> |
Explanation (EN)
Objašnjenje (HR)