@molecule/app-avatar-stack-svelte
Feature · avatar-stack · App (browser) · v1.2.4 · Apache-2.0
Svelte stacked avatars and user-chip component
npm install @molecule/app-avatar-stack-svelteHow it works
@molecule/app-avatar-stack-svelte 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.
<script lang="ts">
import { AvatarStack, UserChip } from '@molecule/app-avatar-stack-svelte'
const people = [
{ name: 'Alice Kim', src: '/avatars/alice.jpg' },
{ name: 'Bob Lee' },
{ name: 'Carol Díaz', src: '/avatars/carol.jpg' },
]
</script>
<!-- Overlapping avatar row for assignees -->
<AvatarStack {people} max={3} size="sm" />
<!-- Single user row in a dropdown -->
<UserChip name="Alice Kim" src="/avatars/alice.jpg">
{#snippet subtitle()}Admin{/snippet}
</UserChip>
<!-- Linked byline: only the name is a profile link. -->
<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-svelte, @molecule/app-ui, @molecule/app-ui-svelte
Reference
Svelte avatar-stack and user-chip components — the Svelte counterpart of
@molecule/app-avatar-stack-react, with the same props and the same DOM.
Exports:
<AvatarStack>— horizontal stack of up tomaxavatars 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-svelte, so
avatar fallbacks (text initials, color hash) come from there.
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.tsJSDoc, not this file.
Quick Start
<script lang="ts">
import { AvatarStack, UserChip } from '@molecule/app-avatar-stack-svelte'
const people = [
{ name: 'Alice Kim', src: '/avatars/alice.jpg' },
{ name: 'Bob Lee' },
{ name: 'Carol Díaz', src: '/avatars/carol.jpg' },
]
</script>
<!-- Overlapping avatar row for assignees -->
<AvatarStack {people} max={3} size="sm" />
<!-- Single user row in a dropdown -->
<UserChip name="Alice Kim" src="/avatars/alice.jpg">
{#snippet subtitle()}Admin{/snippet}
</UserChip>
<!-- Linked byline: only the name is a profile link. -->
<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-svelte @molecule/app-i18n @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte
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 — the same props
@molecule/app-avatar-stack-react accepts. Node props are snippets or plain
strings.
interface UserChipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> {
/** Display name. */
name: string
/** Profile destination. Only the displayed name becomes a link. */
href?: string
/** Name-link attributes and events, including React-compatible `className` and `onClick`. */
nameLinkProps?: Omit<HTMLAnchorAttributes, 'href' | 'children' | 'class'> & {
/** Extra name-link classes. */
className?: string
/** Extra name-link classes (the native Svelte spelling). */
class?: string
/** App router or click handler (the React-compatible spelling). */
onClick?: (event: MouseEvent) => void
}
/** Root click handler (the React-compatible spelling; native `onclick` also works). */
onClick?: (event: MouseEvent) => void
/** Extra root classes (the native Svelte spelling). */
class?: string
/** Optional avatar image URL. */
src?: string
/** Optional secondary line (role / email / handle; a string or a snippet). */
subtitle?: Snippet | string
/** Optional trailing content (action button, status dot, etc.; a snippet). */
trailing?: Snippet
/** Avatar size preset. */
size?: 'xs' | 'sm' | 'md' | 'lg'
/** Extra classes on the outer row. */
className?: string
}
Constants
AvatarStack
const AvatarStack: LegacyComponentType
UserChip
const UserChip: LegacyComponentType
Injection Notes
Requirements
Peer dependencies:
@molecule/app-i18n^1.0.1@molecule/app-svelte^3.13.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-svelte^1.1.0svelte^5.0.0
Runtime Dependencies
@molecule/app-i18n@molecule/app-svelte@molecule/app-ui@molecule/app-ui-sveltesvelte
UserChip with href renders one profile link on the displayed name, with
a decorative avatar outside it. Subtitle and trailing snippets remain outside
the link. nameLinkProps forwards anchor attributes and events; use className
and onClick, or Svelte's native class and onclick, for styling and routing.
Remaining attributes and native event handlers spread onto the outer div;
the root also accepts the React-compatible onClick alias.
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-svelte: 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-svelte. 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. Node-valued props
(subtitle, trailing) are snippets.
Translations
Translation strings are provided by @molecule/app-locales-avatar-stack.