Skip to content

feat(ui): add Mosaic Menu component - #9252

Open
alexcarpenter wants to merge 2 commits into
mainfrom
carp/mosaic-menu
Open

feat(ui): add Mosaic Menu component#9252
alexcarpenter wants to merge 2 commits into
mainfrom
carp/mosaic-menu

Conversation

@alexcarpenter

@alexcarpenter alexcarpenter commented Jul 27, 2026

Copy link
Copy Markdown
Member

Description

Adds a reusable Mosaic Menu to @clerk/ui, styled with StyleX on top of the @clerk/headless menu primitive.

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

Menu.Trigger defaults to a square ghost Button (size='sm') holding an ellipsis glyph; pass children for a labelled trigger, or render to supply your own element. Menu.Content composes the portal, positioner, and popup, so items are the only children consumers write.

<Menu.Root>
  <Menu.Trigger />
  <Menu.Content>
    <Menu.Item label='Add workspace' icon={<PlusIcon />} />
    <Menu.Separator />
    <Menu.Item label='Sign out' onClick={signOut} />
  </Menu.Content>
</Menu.Root>

Styling notes

  • Themed with StyleX (not slot recipes). Each styled part carries a stable .cl-<slot> class (menu-trigger, menu-positioner, menu-popup, menu-item, menu-item-icon, menu-item-label, menu-separator); consumers override from a later CSS layer.
  • Enter/exit transition (opacity + scale) runs off the popup's own data-starting-style / data-ending-style, disabled under prefers-reduced-motion: reduce. Item hover is gated behind @media (hover: hover) and the keyboard-active item styles off data-active, so pointer and keyboard highlighting stay in sync.
  • The popup's max-height tracks --cl-available-height from the positioner, so long menus scroll rather than overflow the viewport.
  • plus and log-out glyphs added to the canonical icon registry (alongside the new ellipsis) rather than duplicated inline.

Build

  • tsdown.mosaic.config.mts now marks @clerk/headless external, matching feat(ui): add Mosaic Popover component #9241. Without it, the bundled .d.ts can't follow headless's extensionless re-export chain in dist/primitives/*/index.d.ts and fails with [MISSING_EXPORT]. Only styles.css ships from this build.
  • Only styles.css ships from the isolated mosaic build; the mosaic JS is not publicly importable yet, so the changeset is empty.

Docs

  • Swingset docs added (menu.component.stories.tsx + .mdx, archetype A · compound) and wired into the registry + docModules. Named menu.component.* so it doesn't collide with the existing headless Menu primitive page.

How to test

  • pnpm --filter @clerk/ui test src/mosaic/components/menu (7 tests)
  • pnpm --filter @clerk/ui build:mosaic — verifies the menu atoms land in styles.css
  • pnpm run dev:swingset → Components → Menu

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🌟 New feature

@vercel

vercel Bot commented Jul 27, 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 29, 2026 12:41am
swingset Ready Ready Preview, Comment Jul 29, 2026 12:41am

Request Review

@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fb372be

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: fb372be

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-07-29T00:41:47.056Z

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 fb372be.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a styled Mosaic Menu API with trigger, content, item, and separator components built on headless primitives. It includes StyleX styles, new icons, public exports, interaction tests, a Storybook story, MDX documentation, registry and documentation-loader integration, and a changeset.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the new Mosaic Menu component and matches the main change.
Description check ✅ Passed The description accurately summarizes the new Mosaic Menu, docs, tests, and build changes.
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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-menu.md:
- Around line 1-2: Replace the empty changeset front matter in mosaic-menu.md
with an `@clerk/ui` minor release entry and add a concise summary describing the
new public Menu API.

In `@packages/swingset/src/stories/menu.component.mdx`:
- Around line 20-29: Update the Menu usage example around Menu.Item to import or
define the PlusIcon symbol before it is passed to the icon prop, ensuring the
snippet is self-contained and valid for TypeScript consumers.

In `@packages/ui/src/mosaic/components/menu/menu.tsx`:
- Around line 44-47: The default icon-only trigger in the menu component is
unnamed for assistive technology. Update the trigger around the children
fallback in packages/ui/src/mosaic/components/menu/menu.tsx:44-47 to provide a
default aria-label of “Open menu” only when children are absent, while
preserving consumer-supplied labels. Update the default-trigger test in
packages/ui/src/mosaic/components/menu/menu.test.tsx:28-36 to query it by role
and accessible name, asserting name: “Open menu”.
🪄 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: ff2ea2bc-f4d7-47ec-88d7-ea1f6b2746e0

📥 Commits

Reviewing files that changed from the base of the PR and between f5d84fe and 015c270.

📒 Files selected for processing (12)
  • .changeset/mosaic-menu.md
  • packages/swingset/src/components/DocsViewer.tsx
  • packages/swingset/src/lib/registry.ts
  • packages/swingset/src/stories/menu.component.mdx
  • packages/swingset/src/stories/menu.component.stories.tsx
  • packages/ui/src/mosaic/components/menu/index.ts
  • packages/ui/src/mosaic/components/menu/menu.styles.ts
  • packages/ui/src/mosaic/components/menu/menu.test.tsx
  • packages/ui/src/mosaic/components/menu/menu.tsx
  • packages/ui/src/mosaic/icons/registry.tsx
  • packages/ui/src/mosaic/styles/index.ts
  • packages/ui/tsdown.mosaic.config.mts
🔗 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 thread .changeset/mosaic-menu.md
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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add an @clerk/ui release entry.

This empty changeset will omit the new public Menu API from the package release and changelog. Add an @clerk/ui minor entry with a concise feature summary.

Proposed fix
 ---
+'`@clerk/ui`': minor
 ---
+
+Add the Mosaic Menu component and menu glyphs.

As per coding guidelines, use Changesets for version management and changelogs. Based on learnings, empty changesets are only appropriate for documentation-only or non-published changes.

📝 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
---
---
---
'`@clerk/ui`': minor
---
Add the Mosaic Menu component and menu glyphs.
🤖 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-menu.md around lines 1 - 2, Replace the empty changeset
front matter in mosaic-menu.md with an `@clerk/ui` minor release entry and add a
concise summary describing the new public Menu API.

Sources: Coding guidelines, Learnings

Comment on lines +20 to +29
```tsx
import { Menu } from '@clerk/ui/mosaic/components/menu';

<Menu.Root>
<Menu.Trigger />
<Menu.Content>
<Menu.Item
label='Add workspace'
icon={<PlusIcon />}
/>

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

Declare the icon used by the usage example.

Line 28 references PlusIcon, but the snippet neither imports nor defines it, so it cannot be copied into a TypeScript consumer.

Proposed fix
 import { Menu } from '`@clerk/ui/mosaic/components/menu`';
+import { iconRegistry } from '`@clerk/ui/mosaic/icons/registry`';
+
+const PlusIcon = iconRegistry.plus;

As per coding guidelines, update documentation for API changes.

📝 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
```tsx
import { Menu } from '@clerk/ui/mosaic/components/menu';
<Menu.Root>
<Menu.Trigger />
<Menu.Content>
<Menu.Item
label='Add workspace'
icon={<PlusIcon />}
/>
import { Menu } from '`@clerk/ui/mosaic/components/menu`';
import { iconRegistry } from '`@clerk/ui/mosaic/icons/registry`';
const PlusIcon = iconRegistry.plus;
<Menu.Root>
<Menu.Trigger />
<Menu.Content>
<Menu.Item
label='Add workspace'
icon={<PlusIcon />}
/>
🤖 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/menu.component.mdx` around lines 20 - 29,
Update the Menu usage example around Menu.Item to import or define the PlusIcon
symbol before it is passed to the icon prop, ensuring the snippet is
self-contained and valid for TypeScript consumers.

Source: Coding guidelines

Comment on lines +44 to +47
{...mergeStyleProps(themeProps('menu-trigger'), className, style)}
{...rest}
>
{children ?? <EllipsisIcon {...stylex.props(styles.triggerIcon)} />}

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 | 🟠 Major | ⚡ Quick win

Make the default icon-only trigger accessible. The default trigger renders only an ellipsis glyph, leaving it unnamed for screen readers; the test currently preserves that regression.

  • packages/ui/src/mosaic/components/menu/menu.tsx#L44-L47: set a default aria-label such as Open menu when children is absent, while allowing a consumer-supplied label to override it.
  • packages/ui/src/mosaic/components/menu/menu.test.tsx#L28-L36: query the default trigger by its accessible name and assert name: 'Open menu'.

As per coding guidelines, implement proper ARIA attributes and comprehensive component tests.

📍 Affects 2 files
  • packages/ui/src/mosaic/components/menu/menu.tsx#L44-L47 (this comment)
  • packages/ui/src/mosaic/components/menu/menu.test.tsx#L28-L36
🤖 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/menu/menu.tsx` around lines 44 - 47, The
default icon-only trigger in the menu component is unnamed for assistive
technology. Update the trigger around the children fallback in
packages/ui/src/mosaic/components/menu/menu.tsx:44-47 to provide a default
aria-label of “Open menu” only when children are absent, while preserving
consumer-supplied labels. Update the default-trigger test in
packages/ui/src/mosaic/components/menu/menu.test.tsx:28-36 to query it by role
and accessible name, asserting name: “Open menu”.

Source: Coding guidelines

Adds a StyleX-themed Menu built on the @clerk/headless menu primitive, with
swingset docs and plus/log-out glyphs in the icon registry.

@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: 1

🤖 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 `@packages/ui/src/mosaic/components/menu/menu.test.tsx`:
- Around line 61-74: Add a keyboard-focused test alongside the existing menu
interaction test, using the menu trigger to open the menu via keyboard, navigate
between items with the appropriate keys, assert the highlighted item changes in
sync with pointer behavior, and activate the selected item. Reuse the existing
renderMenu setup and accessible menu/menuitem symbols, and verify the expected
activation outcome.
🪄 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: a2e5dfaa-d6f4-4457-a238-b5d20f4fb7c3

📥 Commits

Reviewing files that changed from the base of the PR and between 61b2d09 and fb372be.

📒 Files selected for processing (11)
  • .changeset/mosaic-menu.md
  • packages/swingset/src/components/DocsViewer.tsx
  • packages/swingset/src/lib/registry.ts
  • packages/swingset/src/stories/menu.component.mdx
  • packages/swingset/src/stories/menu.component.stories.tsx
  • packages/ui/src/mosaic/components/menu/index.ts
  • packages/ui/src/mosaic/components/menu/menu.styles.ts
  • packages/ui/src/mosaic/components/menu/menu.test.tsx
  • packages/ui/src/mosaic/components/menu/menu.tsx
  • packages/ui/src/mosaic/icons/registry.tsx
  • packages/ui/src/mosaic/styles/index.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)
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/ui/src/mosaic/components/menu/index.ts
  • packages/swingset/src/stories/menu.component.stories.tsx
  • packages/swingset/src/components/DocsViewer.tsx
  • packages/ui/src/mosaic/styles/index.ts
  • packages/swingset/src/stories/menu.component.mdx
  • packages/swingset/src/lib/registry.ts
  • packages/ui/src/mosaic/components/menu/menu.styles.ts
  • .changeset/mosaic-menu.md
  • packages/ui/src/mosaic/components/menu/menu.tsx
  • packages/ui/src/mosaic/icons/registry.tsx

Comment on lines +61 to +74
it('keeps the menu closed until the trigger is clicked', async () => {
const user = userEvent.setup();
renderMenu();
expect(screen.queryByRole('menu')).not.toBeInTheDocument();

await user.click(screen.getByRole('button'));

// `role="menu"` sits on the positioner (floating-ui owns it); the popup is the surface inside.
expect(screen.getByRole('menu')).toHaveClass('cl-menu-positioner');
expect(screen.getByRole('menu').querySelector('.cl-menu-popup')).toBeInTheDocument();
expect(screen.getByRole('menuitem', { name: 'Add workspace' })).toBeInTheDocument();
expect(screen.getByRole('separator')).toHaveClass('cl-menu-separator');
expect(screen.getByTestId('add-icon')).toBeInTheDocument();
});

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 | 🟠 Major | ⚡ Quick win

Add keyboard-navigation coverage.

The suite only opens and exercises the menu with a pointer. Add a test for keyboard opening/navigation and item activation so regressions in the advertised keyboard highlighting path are caught.

As per coding guidelines, “Unit tests are required for all new functionality,” and the PR explicitly includes synchronized pointer/keyboard highlighting.

🤖 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/menu/menu.test.tsx` around lines 61 - 74,
Add a keyboard-focused test alongside the existing menu interaction test, using
the menu trigger to open the menu via keyboard, navigate between items with the
appropriate keys, assert the highlighted item changes in sync with pointer
behavior, and activate the selected item. Reuse the existing renderMenu setup
and accessible menu/menuitem symbols, and verify the expected activation
outcome.

Source: Coding guidelines

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