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
accessibilitysemantic-htmlbuttons
Render clickable actions as a button element, not a styled div
Interactive controls that trigger actions should use a native <button> (or <a> for navigation) rather than a div with onClick. Native elements are keyboard-accessible and announced correctly by screen readers, avoiding aria-role workarounds.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | <div onClick={handleClick}>Submit</div> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | const Tag = href ? 'a' : 'button'; |
| 2 | return <Tag onClick={handleClick} type={href ? undefined : 'button'}>Submit</Tag>; |
Explanation (EN)
Objašnjenje (HR)