Skip to content

feat(Badge): change children to label prop for API consistency #706

Closed

Description

@cixzhang

Problem

Vibe testing shows that LLMs hallucinate <XDSBadge label="Active" /> instead of <XDSBadge>Active</XDSBadge> 100% of the time when Badge docs aren't provided. With docs, they get it right 100%.

The cause: Badge uses children for its text content, but the surrounding components it's commonly used alongside all use label:

  • XDSButton label="Submit"
  • XDSToken label="React"
  • XDSListItem label="Settings"

This creates a strong pattern: short-text leaf components use label. Badge breaks this pattern.

Vibe test results

Condition children label (hallucinated)
With Badge docs 8/8 (100%) 0/8
Without Badge docs 0/8 8/8 (100%)

The test placed Badge alongside Button, Token, and ListItem in realistic scenarios (profile cards, task rows, filter bars, nav items). The label pattern was especially strong in P5 (filter bar with tokens) and P7 (role badges next to buttons).

Proposal

Change Badge's primary text prop from children to label:

// Before
<XDSBadge variant="success">Active</XDSBadge>

// After
<XDSBadge variant="success" label="Active" />

Keep children as a secondary prop for advanced cases (icon-only, custom content), but make label the documented and recommended way to set text.

Migration

Codemod: transform <XDSBadge>text</XDSBadge> → <XDSBadge label="text" /> for string-only children.

Activity

  1. added
    enhancement
    component
    on Mar 19, 2026
  2. added 6 commits that reference this issue on Mar 19, 2026
    f09e80f
    3e562e1
    0b0bbe1
    9848913
    e055509
    e02b4f7
  3. added a commit that references this issue on Mar 19, 2026
    865f2dc
  4. added a commit that references this issue on Apr 26, 2026
    0077fd4
  5. added 2 commits that reference this issue on Jun 21, 2026
    3e700de
    d3a224e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    componentenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions