Skip to content
LoidoltTheme 0.11.1
Svelte 5

Component

Avatar

A person or account, as a photo with initials to fall back on.

import { Avatar } from '@loidolt/theme-svelte';

Example

Label Studio

Notes

  • The avatar has one accessible name, from alt or name, whether the photo or the initials are showing. Leave both unset when adjacent text already names the person.
  • Sizes follow the control heights, so an avatar sits level with buttons of the same size.
  • delayMs holds the initials back briefly, so a photo that loads quickly never flashes them first.

Props

Generated from the component source, so it cannot drift from the implementation.

Avatar props
PropTypeDefaultNotes
alt string—Accessible name when it should differ from name.
class string—
delayMs number0Milliseconds before the fallback appears, so a fast image never flashes initials first.
fallback Snippet—Custom fallback, e.g. a generic person glyph. Replaces the initials.
initials string—Fallback text. Defaults to the first letters of the first and last word of name.
loadingStatus bindableLoadingStatus'loading'
name string—Who this is. Names the avatar for assistive tech and supplies the fallback initials. Leave both name and alt unset when adjacent text already names the person — the avatar is then decorative.
onLoadingStatusChange (status: LoadingStatus) => void—
ref bindableHTMLElement | nullnull
size ControlSize'md'Matches the control heights, so an avatar sits level with buttons of the same size.
src string—Image URL. Without one, or while it loads or after it fails, the fallback shows.

Plus the attributes of Omit< AvatarRootProps, 'child' | 'children' | 'loadingStatus' | 'onLoadingStatusChange' | 'ref' >, forwarded to the root element.