Avatar

Visual representation of a user through images or initials.

Source Tailwind CSS JavaScript

@axadrn AA
@joerdav JD
@axadrn AA
@a-h AH
@joerdav JD
+3

Installation

templui add avatar

Load the script once in your layout:

<head> @avatar.Script() </head>

Examples

Basic

@axadrn AA

Badge

@axadrn AA

Badge with Icon

@axadrn AA

Avatar Group

@axadrn AA
@a-h AH
@joerdav JD

Avatar Group Count

@axadrn AA
@a-h AH
@joerdav JD
+3

Avatar Group with Icon

@axadrn AA
@a-h AH
@joerdav JD

Sizes

@axadrn AA
@axadrn AA
@axadrn AA

API Reference

Required parameter
Hover for description

Avatar

Root container. Compose with Image, Fallback and Badge; stack avatars in a Group.

Name Type Default
Size

Avatar size. Options: 'default' (size-8), 'sm' (size-6), 'lg' (size-10).

Size
default
ID

Optional HTML id for the element.

string
-
Class

Additional CSS classes. Override the size with size-* if needed.

string
-
Attributes

Additional HTML attributes to apply.

templ.Attributes
-

Image

The user's photo.

Name Type Default
Src

Image source URL.

string
-
Alt

Alternative text for the image.

string
-
ID

Optional HTML id for the element.

string
-
Class

Additional CSS classes to apply.

string
-
Attributes

Additional HTML attributes to apply.

templ.Attributes
-

Fallback

Shown when the image fails to load — typically initials.

Name Type Default
ID

Optional HTML id for the element.

string
-
Class

Additional CSS classes to apply.

string
-
Attributes

Additional HTML attributes to apply.

templ.Attributes
-

Badge

A small status dot or icon on the avatar. Stack avatars with Group and GroupCount.

Name Type Default
ID

Optional HTML id for the element.

string
-
Class

Additional CSS classes (e.g. a status color).

string
-
Attributes

Additional HTML attributes to apply.

templ.Attributes
-