Skip to content

Avatar and User Chip

A round picture of a person or thing. It shows the image, and shows Jellyfin's person icon on a gray circle when there is no image or the image fails to load. A status color adds a dot with a name.

Decision

When Use
A picture in a row or table createAvatar
A picture with a name and a line of text beside it createUserChip
A user list with checkboxes User Multi Selector

Usage

import { createAvatar, createUserChip } from './configurationpage?name=myplugin_stolon.js';

row.appendChild(createAvatar({ name: 'Ada Lovelace', status: 'green' }).element);
row.appendChild(createUserChip({ name: 'Ada Lovelace', text: 'Administrator' }).element);

Classes: stolon-avatar, stolon-avatar-small, stolon-avatar-medium, stolon-avatar-large, stolon-avatar-status, stolon-user-chip. Both handles are { element, getValue, setValue, destroy }.

Parts: stolon-avatar-image, stolon-avatar-icon, stolon-user-chip-body, stolon-user-chip-name, stolon-user-chip-text.

States and Modifiers

  • size is small, medium (default), or large. src is the image address. image wins over it, and is an address or a function that returns an address, a Blob, or a promise of one, with the person icon shown until it arrives.
  • An Avatar Stack overlaps several avatars with a +N bubble.
  • With no src, or when the image fails, the avatar shows the person icon on a gray circle, as Jellyfin does for a user with no picture. It carries the stolon-placeholder modifier, and color tints the circle with a color name. name labels it for a screen reader.
  • status is green, red, orange, purple, blue, or gray and adds a dot. statusLabel names the state and defaults to the meaning of the color, such as "Active" for green. The dot has a title and aria-label.
  • createUserChip takes the avatar options and text, a line under the name. With text, the chip carries stolon-two-line and its avatar grows to span both lines.

Reference

Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.

createAvatar

function createAvatar(options?: AvatarOptions): AvatarHandle

A round picture of a person or thing. It shows the image, and shows Jellyfin's person icon when there is no image or the image fails to load. A status color adds a dot with a name.

Option Type What it does
src string image address [optional]
image ThumbSource image address, or a function returning an address, a Blob, or a promise of one, which wins over src [optional]
name string the person's name, for the alt text, the title, and the label of an avatar with no picture [optional]
size 'small' | 'medium' | 'large' | string 'small', 'medium', or 'large' (default 'medium')
color string color name for the circle behind the person icon (default gray)
status 'green' | 'red' | 'orange' | 'purple' | 'blue' | 'gray' | string 'green', 'red', 'orange', 'purple', 'blue', or 'gray' for a status dot [optional]
statusLabel string name of the state (default the color's meaning, such as 'Active' for green)
Handle member Type
getValue (): AvatarOptions
setValue (next: AvatarOptions): void
destroy (): void

createUserChip

function createUserChip(options?: UserChipOptions): UserChipHandle

A pill with an avatar, a name, and an optional second line, for showing who owns or did something.

Option Type What it does
text string
Handle member Type
getValue (): UserChipOptions
setValue (next: UserChipOptions): void
destroy (): void
Class What it looks like
stolon-avatar Round picture, or the person icon on a gray circle, in three sizes, with an optional status dot
stolon-avatar-icon The person icon an avatar shows with no picture, sized to its circle
stolon-avatar-status Dot at the bottom right of an avatar, ringed in the surface color
stolon-user-chip Pill with an avatar, a name, and an optional second line
stolon-user-chip.stolon-two-line A chip with a second line, whose avatar grows to span both lines

Example

Example Code

<!-- title: Avatar -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const view = document.getElementById('view');
const mount = document.getElementById('mount');
mount.style.cssText = 'display:flex;flex-wrap:wrap;align-items:center;gap:12px';
mount.appendChild(base.createAvatar({ name: 'Ada Lovelace', size: 'small' }).element);
mount.appendChild(base.createAvatar({ name: 'Bob Ross', status: 'green' }).element);
mount.appendChild(base.createAvatar({ name: 'Carol', size: 'large', status: 'red', statusLabel: 'Offline' }).element);
mount.appendChild(base.createUserChip({ name: 'Ada Lovelace', text: 'Administrator', status: 'green' }).element);
</script>