@molecule/app-avatar-stack-vue

Feature · avatar-stack · App (browser) · v1.2.3 · Apache-2.0

Vue stacked avatars and user-chip component

npm install @molecule/app-avatar-stack-vue

npm · Source on GitHub

How it works

@molecule/app-avatar-stack-vue is a ready-made avatar-stack feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { createApp, defineComponent, h } from 'vue'
import { AvatarStack, UserChip } from '@molecule/app-avatar-stack-vue'

const Row = defineComponent({
  setup() {
    const people = [
      { name: 'Alice Kim', src: '/avatars/alice.jpg' },
      { name: 'Bob Lee' },
      { name: 'Carol Díaz', src: '/avatars/carol.jpg' },
    ]
    return () =>
      h('div', [
        // Overlapping avatar row for assignees
        h(AvatarStack, { people, max: 3, size: 'sm' }),
        // Single user row in a dropdown
        h(
          UserChip,
          { name: 'Alice Kim', src: '/avatars/alice.jpg' },
          {
            subtitle: () => ['Admin'],
          },
        ),
        // Linked byline: only the name is a profile link.
        h(UserChip, {
          name: 'Alice Kim',
          href: '/people/alice',
          nameLinkProps: { className: 'person-name', target: '_blank', rel: 'noreferrer' },
          'data-person': 'alice',
        }),
      ])
  },
})

createApp(Row).mount('#app')

Works with: @molecule/app-i18n, @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue

Reference

Vue avatar-stack and user-chip components.

Exports:

  • <AvatarStack> — horizontal stack of up to max avatars with a trailing "+N" overflow chip.
  • <UserChip> — avatar + name + optional subtitle row for dropdowns, mention pickers, and row-level user references.

Both render on top of <Avatar> from @molecule/app-ui-vue, so avatar fallbacks (text initials, color hash) come from there. It is the Vue counterpart of @molecule/app-avatar-stack-react: same props (React names) and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { createApp, defineComponent, h } from 'vue'
import { AvatarStack, UserChip } from '@molecule/app-avatar-stack-vue'

const Row = defineComponent({
  setup() {
    const people = [
      { name: 'Alice Kim', src: '/avatars/alice.jpg' },
      { name: 'Bob Lee' },
      { name: 'Carol Díaz', src: '/avatars/carol.jpg' },
    ]
    return () =>
      h('div', [
        // Overlapping avatar row for assignees
        h(AvatarStack, { people, max: 3, size: 'sm' }),
        // Single user row in a dropdown
        h(
          UserChip,
          { name: 'Alice Kim', src: '/avatars/alice.jpg' },
          {
            subtitle: () => ['Admin'],
          },
        ),
        // Linked byline: only the name is a profile link.
        h(UserChip, {
          name: 'Alice Kim',
          href: '/people/alice',
          nameLinkProps: { className: 'person-name', target: '_blank', rel: 'noreferrer' },
          'data-person': 'alice',
        }),
      ])
  },
})

createApp(Row).mount('#app')

Type

feature

Installation

npm install @molecule/app-avatar-stack-vue @molecule/app-i18n @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue

API

Interfaces

AvatarStackPerson

Represents a single person entry rendered inside an AvatarStack.

interface AvatarStackPerson {
  /** Display name (also used to generate the text fallback). */
  name: string
  /** Optional avatar image URL. */
  src?: string
  /** Optional alt text — defaults to `name`. */
  alt?: string
}

AvatarStackProps

Props accepted by the AvatarStack component.

interface AvatarStackProps {
  /** People to render. */
  people: AvatarStackPerson[]
  /** Maximum visible avatars. Remaining are summarised in an "overflow" chip. */
  max?: number
  /** Avatar size preset. */
  size?: 'xs' | 'sm' | 'md' | 'lg'
  /** Extra classes on the outer stack. */
  className?: string
}

UserChipProps

Props accepted by the UserChip component.

interface UserChipProps extends HTMLAttributes {
  /** Display name. */
  name: string
  /** Profile destination. Only the displayed name becomes a link. */
  href?: string
  /** Name-link attributes and events; `className` supplements the default name classes. */
  nameLinkProps?: Omit<AnchorHTMLAttributes, 'href' | 'innerHTML' | 'textContent'> & {
    /** Extra name-link classes (the React-compatible spelling). */
    className?: string
  }
  /** Optional avatar image URL. */
  src?: string
  /**
   * Optional secondary line (role / email / handle). Passed as a prop or as the
   * same-named slot — both work.
   */
  subtitle?: VNodeChild
  /**
   * Optional trailing content (action button, status dot, etc.). Passed as a
   * prop or as the same-named slot — both work.
   */
  trailing?: VNodeChild
  /** Avatar size preset. */
  size?: 'xs' | 'sm' | 'md' | 'lg'
  /** Extra classes on the outer row. */
  className?: string
}

Constants

AvatarStack

Horizontal stack of overlapping avatars (assignees, attendees, etc.).

Renders up to max avatars; any remaining are summarised as +N in a trailing chip. The chip's accessible name (avatarStack.more) and its visible prefix (avatarStack.overflowPrefix) come from useTranslation(), so the chip follows the active locale.

const AvatarStack: DefineComponent<
  ExtractPropTypes<{
    people: { type: PropType<AvatarStackPerson[]>; required: true }
    max: { type: NumberConstructor; default: number }
    size: { type: PropType<'xs' | 'sm' | 'md' | 'lg'>; default: string }
    className: StringConstructor
  }>,
  () => VNode,
  {},
  {},
  {},
  ComponentOptionsMixin,
  ComponentOptionsMixin,
  {},
  string,
  PublicProps,
  Readonly<
    ExtractPropTypes<{
      people: { type: PropType<AvatarStackPerson[]>; required: true }
      max: { type: NumberConstructor; default: number }
      size: { type: PropType<'xs' | 'sm' | 'md' | 'lg'>; default: string }
      className: StringConstructor
    }>
  > &
    Readonly<{}>,
  { max: number; size: 'xs' | 'sm' | 'md' | 'lg' },
  {},
  {},
  {},
  string,
  ComponentProvideOptions,
  true,
  {},
  any
>
  • props — Component props (see AvatarStackProps).

Returns: The avatar stack component.

UserChip

Avatar + name + optional subtitle row — useful in dropdowns, mention pickers, assignment popovers, and row-level user references.

const UserChip: DefineComponent<
  ExtractPropTypes<{
    name: { type: StringConstructor; required: true }
    href: StringConstructor
    nameLinkProps: PropType<UserChipProps['nameLinkProps']>
    src: StringConstructor
    subtitle: null
    trailing: null
    size: { type: PropType<'xs' | 'sm' | 'md' | 'lg'>; default: string }
    className: StringConstructor
  }>,
  () => VNode,
  {},
  {},
  {},
  ComponentOptionsMixin,
  ComponentOptionsMixin,
  {},
  string,
  PublicProps,
  Readonly<
    ExtractPropTypes<{
      name: { type: StringConstructor; required: true }
      href: StringConstructor
      nameLinkProps: PropType<UserChipProps['nameLinkProps']>
      src: StringConstructor
      subtitle: null
      trailing: null
      size: { type: PropType<'xs' | 'sm' | 'md' | 'lg'>; default: string }
      className: StringConstructor
    }>
  > &
    Readonly<{}>,
  { size: 'xs' | 'sm' | 'md' | 'lg' },
  {},
  {},
  {},
  string,
  ComponentProvideOptions,
  true,
  {},
  any
>
  • props — Component props (see UserChipProps).

Returns: The user chip component.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-i18n ^1.0.1
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-vue ^1.1.0
  • @molecule/app-vue ^3.13.0 || ^4.0.0
  • vue ^3.4.0

Runtime Dependencies

  • @molecule/app-i18n
  • @molecule/app-ui
  • @molecule/app-ui-vue
  • @molecule/app-vue
  • vue

UserChip with href renders one profile link on the displayed name, with a decorative avatar outside it. Subtitle and trailing content remain outside the link. nameLinkProps forwards anchor attributes and events (including onClick for app routing); className or Vue's class adds link classes. Remaining root attributes and listeners fall through to the outer div. Without href, the plain avatar/name DOM is unchanged and nameLinkProps is ignored. An empty-string href still renders a link.

The overflow chip announces "+N more" — this is the only user-visible text. Both of its strings come from useTranslation() in @molecule/app-vue: the chip's accessible name is the avatarStack.more key and the sign before its count is avatarStack.overflowPrefix. Add the companion bond @molecule/app-locales-avatar-stack to translate them; without a translation the English defaults render. Avatar fallbacks (initials, color hash) come from <Avatar> in @molecule/app-ui-vue. The overlap is an inline negative left margin (marginLeft: '-0.5rem'), not a ClassMap class: the abstract spacing scale is non-negative, so a negative margin is one of the sanctioned inline-style cases. Node-valued props (subtitle, trailing) arrive as a prop AND a same-named slot; the component accepts either.

Translations

Translation strings are provided by @molecule/app-locales-avatar-stack.