Skip to content

AvatarGroup : add overflow slot for custom tooltip on hidden avatars#6369

Open
Mathu-lmn wants to merge 1 commit intonuxt:v4from
Mathu-lmn:v4
Open

AvatarGroup : add overflow slot for custom tooltip on hidden avatars#6369
Mathu-lmn wants to merge 1 commit intonuxt:v4from
Mathu-lmn:v4

Conversation

@Mathu-lmn
Copy link
Copy Markdown

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This pull request adds support for customizable tooltips on the overflow (“+N”) avatar in the AvatarGroup component.
Added a new section in avatar-group.md with an example on how to use the slot

See #4870 for the original V3 PR

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@github-actions github-actions Bot added the v4 #4488 label Apr 19, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

Added an overflow slot to AvatarGroup that receives { hiddenCount, avatarProps } and allows consumers to override the overflow avatar rendering; the component supplies default avatarProps with text set to +{hiddenCount}. Added a docs section demonstrating using the overflow slot with a tooltip, a Vue example component AvatarGroupOverflowTooltipExample.vue showing max="2" and tooltip-wrapped overflow avatar, and a unit test asserting the slot receives the correct hiddenCount.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding an overflow slot to the AvatarGroup component for custom tooltips on hidden avatars.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of customizable tooltips on the overflow avatar and documentation updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In
`@docs/app/components/content/examples/avatar-group/AvatarGroupOverflowTooltipExample.vue`:
- Line 2: The tooltip string returned by getOverflowTooltip always uses the
plural "teammates", causing "1 more teammates" for a single hidden avatar;
update getOverflowTooltip to return a singular label when hiddenCount is 1
(e.g., "1 more teammate") and the plural for all other counts (e.g., "{n} more
teammates") so the tooltip grammatically matches the count.

In `@docs/content/docs/2.components/avatar-group.md`:
- Line 72: Update the new docs heading "### Overflow tooltip" to include the
unreleased-feature badge by appending :badge{label="Soon"
class="align-text-top"} to that heading so it reads "### Overflow tooltip
:badge{label=\"Soon\" class=\"align-text-top\"}" in
docs/content/docs/2.components/avatar-group.md.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0bb0410-d95d-416d-aafc-7f0a06eb499a

📥 Commits

Reviewing files that changed from the base of the PR and between 92cfda0 and 90393f4.

📒 Files selected for processing (4)
  • docs/app/components/content/examples/avatar-group/AvatarGroupOverflowTooltipExample.vue
  • docs/content/docs/2.components/avatar-group.md
  • src/runtime/components/AvatarGroup.vue
  • test/components/AvatarGroup.spec.ts

@@ -0,0 +1,31 @@
<script setup lang="ts">
const getOverflowTooltip = (hiddenCount: number) => `${hiddenCount} more teammates`
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.

⚠️ Potential issue | 🟡 Minor

Pluralize the tooltip label for the single-hidden-avatar case.

With the current example data, this renders 1 more teammates.

Suggested copy fix
-const getOverflowTooltip = (hiddenCount: number) => `${hiddenCount} more teammates`
+const getOverflowTooltip = (hiddenCount: number) => `${hiddenCount} more teammate${hiddenCount === 1 ? '' : 's'}`
📝 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
const getOverflowTooltip = (hiddenCount: number) => `${hiddenCount} more teammates`
const getOverflowTooltip = (hiddenCount: number) => `${hiddenCount} more teammate${hiddenCount === 1 ? '' : 's'}`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@docs/app/components/content/examples/avatar-group/AvatarGroupOverflowTooltipExample.vue`
at line 2, The tooltip string returned by getOverflowTooltip always uses the
plural "teammates", causing "1 more teammates" for a single hidden avatar;
update getOverflowTooltip to return a singular label when hiddenCount is 1
(e.g., "1 more teammate") and the plural for all other counts (e.g., "{n} more
teammates") so the tooltip grammatically matches the count.

:u-avatar{src="https://github.com/noook.png" alt="Neil Richter" loading="lazy"}
::

### Overflow tooltip
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.

⚠️ Potential issue | 🟡 Minor

Add the unreleased-feature badge to this new docs heading.

This section documents a new slot API, so the heading should carry the Soon badge until the feature ships in the next npm release.

Suggested docs fix
-### Overflow tooltip
+### Overflow tooltip :badge{label="Soon" class="align-text-top"}

As per coding guidelines, docs/**/*.md: Add :badge{label="Soon" class="align-text-top"} to docs headings when introducing new features or fixes, as the docs deploy on merge but features ship on next npm release.

📝 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
### Overflow tooltip
### Overflow tooltip :badge{label="Soon" class="align-text-top"}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/docs/2.components/avatar-group.md` at line 72, Update the new
docs heading "### Overflow tooltip" to include the unreleased-feature badge by
appending :badge{label="Soon" class="align-text-top"} to that heading so it
reads "### Overflow tooltip :badge{label=\"Soon\" class=\"align-text-top\"}" in
docs/content/docs/2.components/avatar-group.md.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@src/runtime/components/AvatarGroup.vue`:
- Line 29: The overflow fallback avatar is still tagged as data-slot="base" and
the overflow slot marker must be carried through avatarProps so consumers/tests
can identify overflow content; update the overflow slot signature (the
overflow?(props: { hiddenCount: number, avatarProps: { text: string, class: any
} }): VNode[] type) and the code that builds/passes avatarProps in
AvatarGroup.vue so that avatarProps includes the data-slot attribute (e.g.,
data-slot="overflow") and ensure the default fallback avatar element binds that
avatarProps, and also apply the same change for the other overflow usage block
around the ~94-108 region so both default and custom slot renderings expose the
same data-slot marker.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 36a8884e-766d-4f3f-a6df-65e0a43c0913

📥 Commits

Reviewing files that changed from the base of the PR and between 90393f4 and a206cea.

📒 Files selected for processing (4)
  • docs/app/components/content/examples/avatar-group/AvatarGroupOverflowTooltipExample.vue
  • docs/content/docs/2.components/avatar-group.md
  • src/runtime/components/AvatarGroup.vue
  • test/components/AvatarGroup.spec.ts
✅ Files skipped from review due to trivial changes (2)
  • docs/content/docs/2.components/avatar-group.md
  • docs/app/components/content/examples/avatar-group/AvatarGroupOverflowTooltipExample.vue


export interface AvatarGroupSlots {
default?(props?: {}): VNode[]
overflow?(props: { hiddenCount: number, avatarProps: { text: string, class: any } }): VNode[]
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.

⚠️ Potential issue | 🟡 Minor

Expose the overflow slot marker through avatarProps.

The fallback overflow avatar is still marked as data-slot="base", so consumers/tests can’t distinguish the new overflow content when using the provided avatarProps. Consider carrying the marker in avatarProps so both the default fallback and custom slot examples keep the same identifier.

Proposed fix
-  overflow?(props: { hiddenCount: number, avatarProps: { text: string, class: any } }): VNode[]
+  overflow?(props: { hiddenCount: number, avatarProps: { text: string, class: any, 'data-slot': string } }): VNode[]
 const overflowAvatarProps = computed(() => ({
   text: `+${hiddenCount.value}`,
-  class: ui.value.base({ class: uiProp.value?.base })
+  class: ui.value.base({ class: uiProp.value?.base }),
+  'data-slot': 'overflow'
 }))
     <slot v-if="hiddenCount > 0" name="overflow" :hidden-count="hiddenCount" :avatar-props="overflowAvatarProps">
-      <UAvatar v-bind="overflowAvatarProps" data-slot="base" />
+      <UAvatar v-bind="overflowAvatarProps" />
     </slot>

As per coding guidelines, src/runtime/components/**/*.vue: “Add data-slot="name" attributes on all template elements to identify slot content”.

Also applies to: 94-108

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/components/AvatarGroup.vue` at line 29, The overflow fallback
avatar is still tagged as data-slot="base" and the overflow slot marker must be
carried through avatarProps so consumers/tests can identify overflow content;
update the overflow slot signature (the overflow?(props: { hiddenCount: number,
avatarProps: { text: string, class: any } }): VNode[] type) and the code that
builds/passes avatarProps in AvatarGroup.vue so that avatarProps includes the
data-slot attribute (e.g., data-slot="overflow") and ensure the default fallback
avatar element binds that avatarProps, and also apply the same change for the
other overflow usage block around the ~94-108 region so both default and custom
slot renderings expose the same data-slot marker.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 19, 2026

npm i https://pkg.pr.new/@nuxt/ui@6369

commit: a206cea

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

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant