Skip to content

feat(ui): add Mosaic Badge component#9221

Open
alexcarpenter wants to merge 1 commit into
mainfrom
carp/mosaic-badge
Open

feat(ui): add Mosaic Badge component#9221
alexcarpenter wants to merge 1 commit into
mainfrom
carp/mosaic-badge

Conversation

@alexcarpenter

@alexcarpenter alexcarpenter commented Jul 22, 2026

Copy link
Copy Markdown
Member

Adds Mosaic Badge. StyleX, span root, one intent axis: primary | secondary | warning | destructive | success.

Preview: https://swingset-git-carp-mosaic-badge.clerkstage.dev/components/badge

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e5fb0a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the ui label Jul 22, 2026
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 22, 2026 8:38pm
swingset Ready Ready Preview, Comment Jul 22, 2026 8:38pm

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9221

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9221

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9221

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9221

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9221

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9221

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9221

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9221

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9221

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9221

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9221

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9221

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9221

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9221

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9221

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9221

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9221

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9221

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9221

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9221

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9221

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9221

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9221

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9221

commit: e5fb0a1

@github-actions

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-07-22T20:39:39.681Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on e5fb0a1.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new Mosaic Badge component with intent variants, StyleX styling, color tokens, forwarded span props, refs, and tests. Adds Storybook stories and MDX documentation for playground, props, usage, and examples. Registers the stories and documentation in Swingset, exposes the component through Mosaic barrels, and adds a changeset.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding the Mosaic Badge component.
Description check ✅ Passed The description directly matches the implemented Badge component, styles, tokens, stories, and Swingset page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/mosaic-badge.md:
- Around line 1-2: Replace the empty frontmatter in mosaic-badge.md with a
changeset entry for `@clerk/ui` using a minor release level, preserving the
required changeset format so the new public Badge component and props API
generate a package bump and changelog entry.

In `@packages/swingset/src/stories/badge.stories.tsx`:
- Around line 1-2: Add the required top-level Emotion JSX import-source pragma
to the badge story before its imports, while preserving the existing BadgeProps
and Badge imports.

In `@packages/ui/src/mosaic/components/badge/badge.tsx`:
- Around line 18-19: Update the Badge component’s prop spread order so rest
props are applied before the component-owned themeProps result, preventing
consumers from overriding the resolved intent metadata. Preserve the existing
style and className resolution, and add a regression test covering an intent
such as success with conflicting rest metadata to verify the resolved intent
wins.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f2fefe08-7668-4d38-97b4-36691ea6f821

📥 Commits

Reviewing files that changed from the base of the PR and between 68ae308 and e5fb0a1.

📒 Files selected for processing (11)
  • .changeset/mosaic-badge.md
  • packages/swingset/src/components/DocsViewer.tsx
  • packages/swingset/src/lib/registry.ts
  • packages/swingset/src/stories/badge.mdx
  • packages/swingset/src/stories/badge.stories.tsx
  • packages/ui/src/mosaic/components/badge/badge.styles.ts
  • packages/ui/src/mosaic/components/badge/badge.test.tsx
  • packages/ui/src/mosaic/components/badge/badge.tsx
  • packages/ui/src/mosaic/components/badge/index.ts
  • packages/ui/src/mosaic/styles/index.ts
  • packages/ui/src/mosaic/tokens.stylex.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)

Comment on lines +1 to +2
---
---

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Add an @clerk/ui release entry.

This introduces a public Badge component and props API, but the empty changeset produces no package bump or changelog entry. Add an appropriate minor @clerk/ui changeset.

Based on learnings, empty changesets are acceptable only for documentation-only or non-published work.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/mosaic-badge.md around lines 1 - 2, Replace the empty frontmatter
in mosaic-badge.md with a changeset entry for `@clerk/ui` using a minor release
level, preserving the required changeset format so the new public Badge
component and props API generate a package bump and changelog entry.

Sources: Coding guidelines, Learnings

Comment on lines +1 to +2
import type { BadgeProps } from '@clerk/ui/mosaic/components/badge';
import { Badge } from '@clerk/ui/mosaic/components/badge';

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required Emotion JSX pragma.

This story renders a styled Mosaic component but lacks the required top-level @jsxImportSource pragma.

+/** `@jsxImportSource` `@emotion/react` */
+
 import type { BadgeProps } from '`@clerk/ui/mosaic/components/badge`';

As per coding guidelines, “Use Emotion pragma /** @jsxImportSource @emotion/react */ at the top of story files that render styled Mosaic components.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import type { BadgeProps } from '@clerk/ui/mosaic/components/badge';
import { Badge } from '@clerk/ui/mosaic/components/badge';
/** `@jsxImportSource` `@emotion/react` */
import type { BadgeProps } from '`@clerk/ui/mosaic/components/badge`';
import { Badge } from '`@clerk/ui/mosaic/components/badge`';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/swingset/src/stories/badge.stories.tsx` around lines 1 - 2, Add the
required top-level Emotion JSX import-source pragma to the badge story before
its imports, while preserving the existing BadgeProps and Badge imports.

Source: Coding guidelines

Comment on lines +18 to +19
{...mergeProps(themeProps('badge', { intent }), stylex.props(styles.base, styles[intent]), className, style)}
{...rest}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prevent consumers from overriding the resolved intent.

...rest can overwrite themeProps('badge', { intent }); e.g. intent='success' data-intent='primary' produces mismatched styling and state metadata. Spread rest before the component-owned props and add a regression test.

Proposed fix
     <span
       ref={ref}
+      {...rest}
       {...mergeProps(themeProps('badge', { intent }), stylex.props(styles.base, styles[intent]), className, style)}
-      {...rest}
     >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{...mergeProps(themeProps('badge', { intent }), stylex.props(styles.base, styles[intent]), className, style)}
{...rest}
<span
ref={ref}
{...rest}
{...mergeProps(themeProps('badge', { intent }), stylex.props(styles.base, styles[intent]), className, style)}
- {...rest}
>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/mosaic/components/badge/badge.tsx` around lines 18 - 19,
Update the Badge component’s prop spread order so rest props are applied before
the component-owned themeProps result, preventing consumers from overriding the
resolved intent metadata. Preserve the existing style and className resolution,
and add a regression test covering an intent such as success with conflicting
rest metadata to verify the resolved intent wins.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant