Skip to content

BbAvatar

Displays an avatar and has a fallback content slot.

import { BbAvatar } from 'bitboss-ui';

On this page

Props

NameDescription
alt Type: stringDefault""

Alternative text for the image, used for accessibility. Without it the avatar is labelled with name.

Describes the photo. When written it wins over name as the accessible name, so leave it empty for a person and pass name.

See example
color Type: string | booleanDefaultfalse

Paints the fallback (initials or icon). true: a palette colour picked from name, stable across renders and the server. A string: any CSS colour or var() as the background, with black or white ink, whichever reads. Unset: the primary colour.

true reads name: without a name the avatar keeps the primary look.

See example
name Type: string

The person's name. With no image and no default slot, the avatar shows its initials (first letters of the first and last word; none: the person icon). Also the accessible name when alt is empty, and the input of color.

Pass it for every person: it is the accessible name and the initials, and the input of color.

See example
pt Type: PtMap<BbAvatarPtPart, never>

Passthrough, object form: the same keys as the pt:* attributes without the prefix. See the pt:<part> row.

pt:<part> Type: PtValue

Passthrough, attribute form: one attribute per part, pt:<part>. Parts: icon, initials, root.

See example
size Type: Responsive<number | CssSize | keyof Sizes>Default"md"

The avatar's width and height: a size-map key, a CSS length ('20px', '2.5rem') or a number of pixels. A single value applies at every breakpoint; a map switches at the breakpoints, as BbButton's size: { default: 'sm', lg: 'xl' }.

The same scale BbIcon reads, so an avatar and an icon line up on the same key. A percentage fills a square parent, which is how an avatar sits in a cell that already has a size.

See example
sizes Type: string

Sizes attribute for the image, used with srcset.

Passes straight through to the <img>, and only means anything alongside srcset.

src Type: string

Source URL of the avatar image.

See example
srcset Type: string

Responsive image source set.

Passes straight through to the <img>, so pair it with sizes or the browser has no width to pick against. The image is center-cropped, so the sources do not need to be pre-cropped square.

timeout Type: numberDefault400

Milliseconds to wait after mount before checking whether the image loaded correctly (SSR fallback).

The deadline is a safety net for prerendered pages, where the image events can fire before hydration. It is not terminal: the <img> stays mounted and a late photo replaces the fallback. Raise it for a slow origin rather than accepting the visible flip.

See example

Slots

The listed properties are the ones exposed to the slot scope.

NameDescription
default Type: Record<string, never>

Fallback content shown when no image source is provided or when the image fails to load. Typically used to render initials or a placeholder icon.

The one sanctioned place to hand-place a BbIcon, because BbAvatar has no icon prop — that is how a bot or a service account gets a brand mark instead of initials. Any slot content replaces the initials of name.

See example