Avatar component

The kit:avatar component is used to display images, icons or initials representing a person or object. It is often used in user interfaces to identify users, profiles or entities. Thanks to its many customization options, the kit:avatar component adapts easily to different styles and contexts.

avatar.svelte
Simone
BO
BY
Laurent

kit:avatar has two rendering modes:

  • Label mode - when label is set, the text is displayed uppercase and centered. size and density scale the avatar in this mode.
  • Image mode - when children is provided instead, the content (typically an <img>) fills the circle. size and density have no effect in this mode.

Examples of avatar

label

Pass a string to label to display initials or short text. The value is trimmed and uppercased automatically.

  • label: string | undefined = undefined
avatar.svelte

Image

Without label, pass an <img> (or any element) as children. The image fills the circle via object-fit: cover.

avatar.svelte

size

Controls the diameter and font size in label mode.

  • size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'md'
avatar.svelte

density

Scales the diameter by a multiplier on top of size, in label mode only.

  • density: 'compact' | 'default' | 'comfortable' = 'default'
avatar.svelte

Without preprocess Lapikit

If you aren’t using the Lapikit preprocessor in svelte.config.js, import the component directly:

API Reference

kit:avatar

propstypedescriptiondefault
labelstringText displayed inside the avatar (uppercased).
sizeenum'xs''sm''md''lg''xl'Diameter and font size. Label mode only.'md'
densityenum'compact''default''comfortable'Size multiplier applied on top of size. Label only.'default'
childrenSnippetContent when label is not set (typically an <img>).

Associate kit:avatar with user Cards or Chips to display roles or status.