templUI is now shadcn-templ. The 2.0 beta is available. Try it

Avatar

Visual representation of a user through images or initials.

Source Tailwind CSS JavaScript

User avatar

Installation

templui add avatar

Load the script once in your layout:

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

Examples

Fallback

John Doe avatarJD

Sizes

Small avatarSM
Default avatarMD
Large avatarLG
Extra large avatarXL

With Icon

Group

User avatarAA
User avatarBB
User avatarCC
+2

API Reference

Required parameter
Hover for description

Avatar

Root container for avatar component. Default size is 8 (size-8). Use the Class prop to customize size and styling.

NameTypeDefault
ID

Unique identifier for the avatar element.

string
-
Class

Additional CSS classes to apply to the avatar. Use this to set custom sizes (e.g. 'size-12', 'size-16') or other styles.

string
-
Attributes

Additional HTML attributes to apply to the avatar element.

templ.Attributes
-

Image

Image element within the avatar that displays the user's photo.

NameTypeDefault
ID

Unique identifier for the image element.

string
-
Class

Additional CSS classes to apply to the image.

string
-
Attributes

Additional HTML attributes to apply to the image element.

templ.Attributes
-
Src

Image source URL.

string
-
Alt

Alternative text for the image.

string
-

Fallback

Fallback element displayed when the image fails to load, typically showing initials or an icon.

NameTypeDefault
ID

Unique identifier for the fallback element.

string
-
Class

Additional CSS classes to apply to the fallback.

string
-
Attributes

Additional HTML attributes to apply to the fallback element.

templ.Attributes
-