Skip to content

feat(ui): add Avatar button composition - #9378

Merged
austincalvelage merged 6 commits into
mainfrom
austin/user-profile-03-avatar-button
Aug 12, 2026
Merged

feat(ui): add Avatar button composition#9378
austincalvelage merged 6 commits into
mainfrom
austin/user-profile-03-avatar-button

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Aug 10, 2026

Copy link
Copy Markdown
Member

Description

https://swingset-git-austin-user-profile-03-avatar-button.clerkstage.dev/components/avatar

Adds support for Avatar button this will eventually be used in a component like

<AvatarUploader /> as the trigger.

  • Adds render support to Avatar.Root, allowing the avatar to render as a button or dialog trigger without an additional wrapper.
  • Adds the Avatar.Icon
  • Adds the pen glyph to the Mosaic icon registry.
  • Adds the --cl-color-avatar-icon token so the edit icon can be themed independently.
import { Avatar } from '@clerk/ui/mosaic/components/avatar';
import { Button } from '@clerk/ui/mosaic/components/button';
import { Icon } from '@clerk/ui/mosaic/components/icon';

<Avatar.Root
  size='lg'
  render={
    <button
      aria-label='Edit profile picture'
    />
  }
>
  <Avatar.Image
    src='https://avatars.githubusercontent.com/u/51144033?v=4'
    alt='Colin'
  />
  <Avatar.Fallback>CL</Avatar.Fallback>
  <Avatar.Icon>
    <Icon name='pen' />
  </Avatar.Icon>
</Avatar.Root>;

@vercel

vercel Bot commented Aug 10, 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 Aug 12, 2026 4:40pm
swingset Ready Ready Preview Aug 12, 2026 4:40pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b90fcfe

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 Aug 10, 2026
@austincalvelage
austincalvelage force-pushed the austin/user-profile-02-settings-group branch from 952b17c to 4bf4850 Compare August 10, 2026 22:22
@austincalvelage
austincalvelage force-pushed the austin/user-profile-03-avatar-button branch from 15a0874 to ddc1588 Compare August 10, 2026 22:22
@austincalvelage
austincalvelage force-pushed the austin/user-profile-02-settings-group branch from 4bf4850 to c3ce60e Compare August 11, 2026 16:26
@austincalvelage
austincalvelage force-pushed the austin/user-profile-03-avatar-button branch from ddc1588 to de3c66b Compare August 11, 2026 16:26
@austincalvelage
austincalvelage force-pushed the austin/user-profile-03-avatar-button branch from de3c66b to 3295120 Compare August 11, 2026 16:42
@austincalvelage
austincalvelage force-pushed the austin/user-profile-02-settings-group branch from c3ce60e to a3b0bd3 Compare August 11, 2026 16:42
@austincalvelage
austincalvelage force-pushed the austin/user-profile-02-settings-group branch from a3b0bd3 to ef07a60 Compare August 11, 2026 17:25
@austincalvelage
austincalvelage force-pushed the austin/user-profile-03-avatar-button branch from 3295120 to ab14db8 Compare August 11, 2026 17:25
@austincalvelage
austincalvelage force-pushed the austin/user-profile-02-settings-group branch from ef07a60 to 5a6ccdb Compare August 12, 2026 00:29
@austincalvelage
austincalvelage force-pushed the austin/user-profile-03-avatar-button branch from ab14db8 to f711e0e Compare August 12, 2026 01:27
@austincalvelage
austincalvelage changed the base branch from austin/user-profile-02-settings-group to main August 12, 2026 01:27
@austincalvelage austincalvelage changed the title feat(ui): add AvatarButton block feat(ui): add interactive Avatar composition Aug 12, 2026
@austincalvelage austincalvelage changed the title feat(ui): add interactive Avatar composition feat(ui): add Avatar Button Aug 12, 2026
@vercel
vercel Bot temporarily deployed to Preview – clerk-js-sandbox August 12, 2026 01:36 Inactive
@austincalvelage austincalvelage changed the title feat(ui): add Avatar Button feat(ui): add Avatar button composition Aug 12, 2026
@austincalvelage
austincalvelage marked this pull request as ready for review August 12, 2026 01:49
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-12T16:41:25.917Z

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 99436f5.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: f0bb9294-93c6-4692-b831-fa2e1fb2a4f1

📥 Commits

Reviewing files that changed from the base of the PR and between 926c92a and b90fcfe.

📒 Files selected for processing (3)
  • packages/swingset/src/lib/registry.ts
  • packages/ui/src/mosaic/components/avatar/avatar.styles.ts
  • 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)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/ui/src/mosaic/styles/index.ts
  • packages/swingset/src/lib/registry.ts
  • packages/ui/src/mosaic/components/avatar/avatar.styles.ts

📝 Walkthrough

Walkthrough

The Avatar component now supports rendering onto custom elements such as buttons. It adds the optional Avatar.Icon component and related styles. The icon registry adds a filled Pen glyph. Tests cover button composition, ref and prop forwarding, accessibility, and context validation. Stories, documentation, public type exports, and Changesets are updated.

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

Possibly related PRs

  • clerk/javascript#9234: Both PRs modify Mosaic Avatar styling and interactive composition.
  • clerk/javascript#9398: Both PRs modify the Avatar component, styles, tests, and documentation, including fallback behavior.

Suggested reviewers: maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% 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
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.
Title check ✅ Passed The title clearly summarizes the main change: composing Avatar.Root as an interactive button.
Description check ✅ Passed The description directly explains the interactive Avatar changes, including render support, Avatar.Icon, and the pen glyph.

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: 2

🤖 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/avatar-button-block.md:
- Around line 1-2: Add a non-empty Changeset entry for `@clerk/ui` declaring a
minor release and summarize the newly public Avatar.Root.render, Avatar.Icon,
and AvatarIconProps APIs.

In `@packages/swingset/src/stories/avatar.mdx`:
- Line 5: Rework the Avatar documentation page to follow the compound-component
structure: use the sections Example, Usage, Parts, and Styling in that exact
order. Replace the existing Playground, Props, and Examples structure, and
remove all Preview and PropTable usage while preserving the Avatar component
details.
🪄 Autofix

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: 87c92f21-8289-4db6-b64c-5d034cf31131

📥 Commits

Reviewing files that changed from the base of the PR and between 44edcc9 and 3c92f74.

📒 Files selected for processing (12)
  • .changeset/avatar-button-block.md
  • packages/swingset/src/lib/registry.ts
  • packages/swingset/src/stories/avatar.mdx
  • packages/swingset/src/stories/avatar.stories.tsx
  • packages/ui/src/mosaic/components/avatar/avatar.styles.ts
  • packages/ui/src/mosaic/components/avatar/avatar.test.tsx
  • packages/ui/src/mosaic/components/avatar/avatar.tsx
  • packages/ui/src/mosaic/components/avatar/index.ts
  • packages/ui/src/mosaic/components/icon/icon.test.tsx
  • packages/ui/src/mosaic/icons/registry.tsx
  • 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)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)

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 a release entry for @clerk/ui.

This PR adds public Avatar.Root.render, Avatar.Icon, and AvatarIconProps. An empty Changeset will not create a package version or changelog entry for consumers. Add an @clerk/ui minor release entry with a concise summary.

Based on learnings, empty Changesets are acceptable only when no published package requires release metadata. As per coding guidelines, “Use Changesets for version management and changelogs.”

🤖 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/avatar-button-block.md around lines 1 - 2, Add a non-empty
Changeset entry for `@clerk/ui` declaring a minor release and summarize the newly
public Avatar.Root.render, Avatar.Icon, and AvatarIconProps APIs.

Sources: Coding guidelines, Learnings

# Avatar

Avatar represents a user or entity as an image, falling back to a blank placeholder when the image is missing or fails to load. It is a compound component: `Avatar.Root` clips and sizes the box, `Avatar.Image` renders the picture once it loads, and `Avatar.Fallback` holds the space until then.
Avatar represents a user or entity as an image, falling back to a blank placeholder when the image is missing or fails to load. It is a compound component: `Avatar.Root` positions and sizes the box, `Avatar.Image` renders the picture once it loads, `Avatar.Fallback` holds the space until then, and `Avatar.Icon` adds an optional corner affordance.

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 | 🏗️ Heavy lift

Use the required compound-component documentation archetype.

Avatar is a compound component, but this page uses Playground, Props, and Examples. It also uses <Preview> and <PropTable>. Replace the page structure with Example, Usage, Parts, then Styling. Remove <Preview> and <PropTable>.

As per coding guidelines, “Compound Components pages must use the exact section order: Example, Usage, Parts, then Styling, with no <Preview> or <PropTable>.”

🤖 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/avatar.mdx` at line 5, Rework the Avatar
documentation page to follow the compound-component structure: use the sections
Example, Usage, Parts, and Styling in that exact order. Replace the existing
Playground, Props, and Examples structure, and remove all Preview and PropTable
usage while preserving the Avatar component details.

Source: Coding guidelines

@alexcarpenter alexcarpenter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stacked a PR with some suggested changes here #9413

  • when using a button trigger, we'd likely just use a Headless Button vs our styled Button to avoid the overrides you needed to add
  • icon viewbox is wonky, we shouldn't need to override viewboxes and keep them consistent at 0 0 16 16. not sure whats up with the pen icon, looks like it came from ceramic which has some goofy stuff going on with strokes

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
.changeset/mosaic-avatar-interactive-styles.md (1)

1-3: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a non-empty @clerk/ui Changeset for the Avatar changes.

All three Avatar-related Changesets are empty. The existing @clerk/ui Changeset covers unrelated billing changes. Remove the empty placeholders after adding the Avatar package bump and release note.

🤖 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-avatar-interactive-styles.md around lines 1 - 3, Replace
the empty front matter in mosaic-avatar-interactive-styles.md with a non-empty
`@clerk/ui` Changeset that bumps the package appropriately and includes a release
note describing the Avatar changes, then remove the other empty Avatar-related
Changeset placeholders while preserving the unrelated billing Changeset.

Source: Coding guidelines

packages/ui/src/mosaic/components/avatar/avatar.styles.ts (1)

80-96: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Consume --cl-color-avatar-icon in Avatar.Icon.

themeProps('avatar-icon') only adds the .cl-avatar-icon class. No avatar-icon selector or --cl-color-avatar-icon declaration exists. Define the token and apply it as the icon color so theme overrides affect the affordance.

🤖 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/avatar/avatar.styles.ts` around lines 80 -
96, Update the Avatar icon styles in the icon definition to declare the
--cl-color-avatar-icon token and apply it to the icon’s color property. Ensure
Avatar.Icon consumes this token so theme overrides affect the affordance, while
preserving the existing layout and border styles.
🤖 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/avatar/avatar.styles.ts`:
- Around line 26-38: Update the interactive avatar styles to reset native button
rendering by adding appearance: none and a transparent background alongside the
existing border, outline, and cursor rules. Keep the current focus-visible and
disabled-state behavior unchanged.

In `@packages/ui/src/mosaic/components/avatar/avatar.tsx`:
- Around line 39-47: Update AvatarProps and the AvatarRoot render path so
AvatarProps.render only accepts interactive element targets, or require an
explicit interactive condition before applying styles.interactive. Use the
existing interactive value derived from render and the AvatarRoot/useRender
symbols, preserving non-interactive avatar behavior without pointer or focus
styling.

---

Outside diff comments:
In @.changeset/mosaic-avatar-interactive-styles.md:
- Around line 1-3: Replace the empty front matter in
mosaic-avatar-interactive-styles.md with a non-empty `@clerk/ui` Changeset that
bumps the package appropriately and includes a release note describing the
Avatar changes, then remove the other empty Avatar-related Changeset
placeholders while preserving the unrelated billing Changeset.

In `@packages/ui/src/mosaic/components/avatar/avatar.styles.ts`:
- Around line 80-96: Update the Avatar icon styles in the icon definition to
declare the --cl-color-avatar-icon token and apply it to the icon’s color
property. Ensure Avatar.Icon consumes this token so theme overrides affect the
affordance, while preserving the existing layout and border styles.
🪄 Autofix

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: de7da63b-6028-4393-a2ec-7f0eee681957

📥 Commits

Reviewing files that changed from the base of the PR and between 3c92f74 and 926c92a.

📒 Files selected for processing (6)
  • .changeset/mosaic-avatar-interactive-styles.md
  • packages/swingset/src/stories/avatar.stories.tsx
  • packages/ui/src/mosaic/components/avatar/avatar.styles.ts
  • packages/ui/src/mosaic/components/avatar/avatar.test.tsx
  • packages/ui/src/mosaic/components/avatar/avatar.tsx
  • packages/ui/src/mosaic/icons/registry.tsx
🔗 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)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ui/src/mosaic/icons/registry.tsx

Comment thread packages/ui/src/mosaic/components/avatar/avatar.styles.ts
Comment thread packages/ui/src/mosaic/components/avatar/avatar.tsx
@austincalvelage
austincalvelage force-pushed the austin/user-profile-03-avatar-button branch from b90fcfe to 99436f5 Compare August 12, 2026 16:37
@austincalvelage
austincalvelage merged commit 9364612 into main Aug 12, 2026
54 checks passed
@austincalvelage
austincalvelage deleted the austin/user-profile-03-avatar-button branch August 12, 2026 19:24
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.

2 participants