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 ruleP1universalStack: React
accessibilitysemanticstypographyreact
Preserve the original semantic tag when changing typography variants
Switching a Typography variant should not silently change the rendered HTML tag; pass component="h2" (or the original tag) to keep semantics and avoid layout/a11y regressions.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | // variant change flips the tag from <h2> to <span> |
| 2 | <Typography variant="body">{title}</Typography> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // retain the heading tag explicitly |
| 2 | <Typography variant="body" component="h2">{title}</Typography> |
Explanation (EN)
Objašnjenje (HR)