@molecule/app-avatar-stack-solid

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

Solid stacked avatars and user-chip component

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

npm · Source on GitHub

How it works

@molecule/app-avatar-stack-solid 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 { AvatarStack, UserChip } from '@molecule/app-avatar-stack-solid'

const people = [
  { name: 'Alice Kim', src: '/avatars/alice.jpg' },
  { name: 'Bob Lee' },
  { name: 'Carol Díaz', src: '/avatars/carol.jpg' },
]

export function Assignees() {
  return (
    <>
      <AvatarStack people={people} max={3} size="sm" />
      <UserChip name="Alice Kim" src="/avatars/alice.jpg" subtitle="Admin" />
      <UserChip
        name="Alice Kim"
        href="/people/alice"
        data-person="alice"
        nameLinkProps={{ className: 'person-name', target: '_blank', rel: 'noreferrer' }}
      />
    </>
  )
}

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

Reference

Solid 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-solid, so avatar fallbacks (text initials, color hash) come from there. It is the Solid 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 { AvatarStack, UserChip } from '@molecule/app-avatar-stack-solid'

const people = [
  { name: 'Alice Kim', src: '/avatars/alice.jpg' },
  { name: 'Bob Lee' },
  { name: 'Carol Díaz', src: '/avatars/carol.jpg' },
]

export function Assignees() {
  return (
    <>
      <AvatarStack people={people} max={3} size="sm" />
      <UserChip name="Alice Kim" src="/avatars/alice.jpg" subtitle="Admin" />
      <UserChip
        name="Alice Kim"
        href="/people/alice"
        data-person="alice"
        nameLinkProps={{ className: 'person-name', target: '_blank', rel: 'noreferrer' }}
      />
    </>
  )
}

Type

feature

Installation

npm install @molecule/app-avatar-stack-solid @molecule/app-i18n @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js

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 JSX.HTMLAttributes<HTMLDivElement> {
  /** Display name. */
  name: string
  /** Profile destination. Only the displayed name becomes a link. */
  href?: string
  /** Name-link attributes and events, including app styling and SPA navigation. */
  nameLinkProps?: Omit<
    JSX.AnchorHTMLAttributes<HTMLAnchorElement>,
    'href' | 'children' | 'innerHTML' | 'textContent'
  > & {
    /** Extra name-link classes (the React-compatible spelling). */
    className?: string
  }
  /** Optional avatar image URL. */
  src?: string
  /** Optional secondary line (role / email / handle). */
  subtitle?: JSX.Element
  /** Optional trailing content (action button, status dot, etc.). */
  trailing?: JSX.Element
  /** Avatar size preset. */
  size?: 'xs' | 'sm' | 'md' | 'lg'
  /** Extra classes on the outer row. */
  className?: string
}

Functions

AvatarStack(props)

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.

function AvatarStack(props: AvatarStackProps): JSX.Element
  • props — Component props (see AvatarStackProps).

Returns: The rendered avatar stack.

UserChip(props)

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

function UserChip(props: UserChipProps): JSX.Element
  • props — Component props (see UserChipProps).

Returns: The rendered user chip.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-i18n ^1.0.1
  • @molecule/app-solid ^3.14.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-solid ^1.1.0
  • solid-js ^1.8.0

Runtime Dependencies

  • @molecule/app-i18n
  • @molecule/app-solid
  • @molecule/app-ui
  • @molecule/app-ui-solid
  • solid-js

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 Solid's class adds link classes. Remaining root attributes and events pass through to the outer div via splitProps. 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-solid: 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-solid. The overlap is an inline negative left margin (margin-left: '-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.

Translations

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