Skip to content

feat(react-components): add size variant to Badge - #148

Open
RomanPogorov wants to merge 1 commit into
masterfrom
badge-size-variant
Open

feat(react-components): add size variant to Badge#148
RomanPogorov wants to merge 1 commit into
masterfrom
badge-size-variant

Conversation

@RomanPogorov

Copy link
Copy Markdown
Contributor

Problem

Badge hard-codes its spacing and type in the base styles (px-2 py-0.5 text-xs) and exposes no size prop — only variant. Anything larger has to be patched at the call site via className, so each consumer ends up with its own ad-hoc numbers.

Concretely: on the Smartbox admin app-review screen, badges sit next to the app name as its status and classification. At text-xs they read as a footnote rather than as peers of the heading beside them.

Change

Spacing/type move out of the base into a size variant with two steps:

size classes
regular (default) px-2 py-0.5 text-xs + [&>svg]:size-3
large px-2.5 py-1 text-sm + [&>svg]:size-3.5

regular reproduces the previous values exactly and is the default, so existing usages render identically — no visual diff anywhere in any consumer.

Naming follows Button, which already defaults to size: "regular".

Notes

  • Icon sizing follows the step, so an icon inside a large badge doesn't stay undersized.
  • Storybook Component/Badge gains a row demonstrating both sizes, including large with an icon.
  • biome check passes on both touched files.

Badge had its spacing and type hard-coded in the base styles, so the only
way to get anything other than text-xs/py-0.5 was to override the class
list at the call site — which every consumer then does slightly
differently.

Move those into a `size` variant with two steps:

  regular  px-2   py-0.5  text-xs   (default)
  large    px-2.5 py-1    text-sm

`regular` reproduces the previous values exactly and is the default, so
this is not a visual change for existing usages. `large` covers badges
that sit next to a heading or carry a page-level status, where text-xs
reads as a footnote rather than a peer of the title beside it.

Icon sizing follows the step (size-3 / size-3.5).
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