Skip to content

fix: use span instead of div for Badge - #89

Open
juliag106 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
juliag106:fix/badge-semantic-element
Open

fix: use span instead of div for Badge#89
juliag106 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
juliag106:fix/badge-semantic-element

Conversation

@juliag106

Copy link
Copy Markdown

Background

The Badge component renders a div element, which is block-level by default. Badges in this codebase are styled with inline-flex and used inline with text or inside flex containers. Using a block-level element for an inline UI piece is semantically incorrect and can cause subtle layout issues when badges appear mid-paragraph.

Changes

In frontend/src/components/ui/badge.tsx:

  • Changed the rendered element from div to span (inline-level, matching the inline-flex display style)
  • Updated the BadgeProps interface from HTMLAttributes of HTMLDivElement to HTMLAttributes of HTMLSpanElement to match the actual element

Notes

The inline-flex class on the badge variants already compensates for display behavior, so visual rendering is unchanged. The fix is purely about using the semantically correct HTML element. No callers pass block-specific props that would break.

Verified by reviewing all Badge usage across the frontend. All call sites pass standard HTML attributes (className, children, onClick) that are common to both div and span.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant