Skip to content

feat(react-headless-components-preview): add CounterBadge and PresenceBadge - #36674

Open
Dmytro Kirpa (dmytrokirpa) wants to merge 1 commit into
microsoft:masterfrom
dmytrokirpa:dmytrokirpa/headless-badge-variants
Open

feat(react-headless-components-preview): add CounterBadge and PresenceBadge#36674
Dmytro Kirpa (dmytrokirpa) wants to merge 1 commit into
microsoft:masterfrom
dmytrokirpa:dmytrokirpa/headless-badge-variants

Conversation

@dmytrokirpa

Copy link
Copy Markdown
Contributor

Previous Behavior

The headless Badge subpath exported only the base Badge primitive. CounterBadge and PresenceBadge behavior was available only through the styled react-badge package.

New Behavior

  • Adds headless CounterBadge and PresenceBadge primitives under the existing Badge family.
  • Exports their stable components, hooks, renderers, props, states, and PresenceBadgeStatus from the existing ./badge subpath.
  • Adds typed state attributes for count, dot, hidden, overflow, presence status, and out-of-office state.
  • Adds separate Badge, CounterBadge, and PresenceBadge stories, including an out-of-office presence story using Fluent React icons.
  • Moves the base Badge implementation into the nested Badge family folder for consistent organization.

Related Issue(s)

None.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e2f35405-d3b7-404c-853d-cd79e34a0d2d
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-headless-components-preview
react-headless-components-preview: entire library
239.001 kB
67.292 kB
240.311 kB
67.804 kB
1.31 kB
512 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-headless-components-preview
@fluentui/react-headless-components-preview/tag-picker
53.998 kB
17.753 kB
react-headless-components-preview
@fluentui/react-headless-components-preview/teaching-popover
36.058 kB
12 kB
🤖 This report was generated against 26484860c01052d6c4482a1875f0c75b5c6670ce

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Pull request demo site: URL

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds headless CounterBadge and PresenceBadge primitives alongside the reorganized Badge family.

Changes:

  • Adds components, state attributes, exports, API documentation, and tests.
  • Adds Storybook examples and styling.
  • Reorganizes Badge under a nested family structure.

Merge confidence: 70/100

Reviewed changes

Copilot reviewed 29 out of 34 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
stories/src/PresenceBadge/PresenceBadgeOutOfOffice.stories.tsx Adds out-of-office examples.
stories/src/PresenceBadge/PresenceBadgeDescription.md Documents PresenceBadge usage.
stories/src/PresenceBadge/PresenceBadgeDefault.stories.tsx Adds status examples.
stories/src/PresenceBadge/presence-badge.module.css Styles presence states.
stories/src/PresenceBadge/index.stories.tsx Registers PresenceBadge stories.
stories/src/CounterBadge/index.stories.tsx Registers CounterBadge stories.
stories/src/CounterBadge/CounterBadgeDescription.md Documents CounterBadge behavior.
stories/src/CounterBadge/CounterBadgeDefault.stories.tsx Adds counter examples.
stories/src/CounterBadge/counter-badge.module.css Styles counter states.
stories/src/Badge/index.stories.tsx Reorganizes Badge stories.
stories/src/Badge/BadgeDescription.md Clarifies Badge semantics.
stories/src/Badge/BadgeDefault.stories.tsx Updates story formatting.
stories/src/Badge/badge.module.css Tokenizes and refines styles.
library/src/components/Badge/PresenceBadge/usePresenceBadge.ts Adds presence state attributes.
library/src/components/Badge/PresenceBadge/renderPresenceBadge.ts Exposes the renderer.
library/src/components/Badge/PresenceBadge/PresenceBadge.types.ts Defines public state types.
library/src/components/Badge/PresenceBadge/PresenceBadge.tsx Implements PresenceBadge.
library/src/components/Badge/PresenceBadge/PresenceBadge.test.tsx Tests presence behavior.
library/src/components/Badge/PresenceBadge/index.ts Exports PresenceBadge APIs.
library/src/components/Badge/CounterBadge/useCounterBadge.ts Adds counter state attributes.
library/src/components/Badge/CounterBadge/renderCounterBadge.ts Exposes the renderer.
library/src/components/Badge/CounterBadge/index.ts Exports CounterBadge APIs.
library/src/components/Badge/CounterBadge/CounterBadge.types.ts Defines public state types.
library/src/components/Badge/CounterBadge/CounterBadge.tsx Implements CounterBadge.
library/src/components/Badge/CounterBadge/CounterBadge.test.tsx Tests counter behavior.
library/src/components/Badge/Badge/useBadge.ts Preserves Badge state behavior.
library/src/components/Badge/Badge/renderBadge.tsx Re-exports Badge rendering.
library/src/components/Badge/Badge/index.ts Exports Badge APIs.
library/src/components/Badge/Badge/Badge.types.ts Defines Badge state attributes.
library/src/components/Badge/Badge/Badge.tsx Relocates Badge implementation.
library/src/components/Badge/Badge/Badge.test.tsx Updates relocated tests.
library/src/badge.ts Expands the badge subpath API.
library/etc/badge.api.md Records the expanded API surface.
change/@fluentui-react-headless-components-preview-3f13119d-36b2-4af8-8dd6-bdfac92e2d2a.json Adds release metadata.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -0,0 +1,7 @@
{
"type": "patch",
...state.root,
'data-count': String(state.count),
'data-dot': state.dot ? '' : undefined,
'data-hidden': !state.root.children && !state.dot ? '' : undefined,
Comment on lines +8 to +12
<CounterBadge className={styles.counterBadge} count={4} aria-label="4 notifications" />
<CounterBadge className={styles.counterBadge} count={100} aria-label="More than 99 notifications" />
<CounterBadge className={styles.counterBadge} count={0} showZero aria-label="No notifications" />
<CounterBadge className={styles.counterBadge} dot aria-label="New activity" />
<CounterBadge className={styles.counterBadge} count={0} aria-label="Hidden empty counter" />
border-radius: var(--radius-pill);
background: var(--brand);
color: var(--text-on-accent);
font-weight: 600;
'data-count': String(state.count),
'data-dot': state.dot ? '' : undefined,
'data-hidden': !state.root.children && !state.dot ? '' : undefined,
'data-overflowed': state.count > overflowCount ? '' : undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't we using the toDataAttributeValue util anymore?

root: {
...state.root,
'data-status': state.status,
'data-out-of-office': state.outOfOffice ? '' : undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'data-out-of-office': state.outOfOffice ? '' : undefined,
'data-out-of-office': toDataAttributeValue(state.outOfOffice),

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants