Skip to content

Avatar

Shows who a user is: their photo, their initials on a tinted background, or an icon.

image sets the picture as a background image. Without it, the children (initials, an icon) are centered in the avatar.

name renders the initials of a person without an image or children: the first letter of the first two words, uppercased (“Jane Doe” gives “JD”, “élodie” gives “É”). It also labels the avatar, whose picture is a background image and initials are not a name: role="img", and the name as title (a tooltip on hover) and aria-label. Pass title or aria-label yourself to replace them.

color gives the avatar one of Tabler’s colors (bg-{color}-lt): blue azure indigo purple pink red orange yellow lime green teal cyan. It takes precedence over variant. auto picks one from the name, so a person keeps the same color on every page:

Twig has no hash function, so auto sums the positions of the characters of the lowercased, URL-encoded name in a fixed alphabet, modulo the 12 colors. It is stable, but not a real hash: different names can share a color. Without a name, auto sets no color.

size goes from xxs to 2xl; md is the default.

variant gives initials or icons a tinted background (bg-{variant}-lt), from a theme color or one of Tabler’s colors (blue … cyan, as for color):

Avatars are round in Tabler 1.6. square switches to rounded corners (avatar-square). rounded adds Bootstrap’s rounded-circle, which forces a circle when your CSS gives avatars another shape.

cover pulls the avatar up by half its height over the element above it, such as a Card:Cover, and draws a ring in the card background around it (avatar-cover):

Avatar:List spaces several avatars in a row (avatar-list). stacked overlaps them (avatar-list-stacked), and size sizes every avatar in the list (avatar-list-{size}):

Its items renders an avatar for each entry, an array of Avatar props: image, name, variant, color, size, rounded, square and tooltip, all optional. text replaces the initials, e.g. for a counter of the remaining people; it is escaped:

tooltip sets the title and data-bs-toggle="tooltip" on the avatar itself, which tabler.js turns into a Bootstrap tooltip, with no wrapper, so stacked avatars keep overlapping. With a name, the tooltip replaces the title and the name stays the aria-label. Attributes you pass yourself (title, data-bs-toggle) win:

Avatar:Brand adds a small mark in the bottom corner of an avatar (avatar-brand), e.g. the service an account comes from. Put it in the avatar, with an image or with markup such as an icon:

Avatar:Upload is a dashed empty slot for a picture that is not set yet (avatar-upload). It renders a <button type="button">, or an <a> with href. icon and text fill it; children replace both:

Prop Type Default Description
size string 'md' xxs xs sm md lg xl 2xl
variant string? null Tinted background: primary secondary success danger warning info dark light, or a Tabler color blue … cyan
rounded bool false Circle (rounded-circle)
square bool false Rounded corners instead of a circle (avatar-square)
cover bool false Pulled over the element above, with a ring (avatar-cover)
image string? null Image URL, set as an inline background-image style
name string? null Name of the person: initials without image, role="img", title and aria-label
color string? null Tabler color of the background (bg-{color}-lt), or auto to pick it from the name
tooltip string? null Tooltip text (title, data-bs-toggle="tooltip"), replacing the title of name

Other attributes go to the root <span class="avatar">. A style attribute is merged after the background-image, so it can still override it.

Avatar:List:

Prop Type Default Description
stacked bool false Overlaps the avatars (avatar-list-stacked)
size string? null xxs xs sm md lg xl 2xl: sizes every avatar (avatar-list-{size})
items array? null Avatars to render: {image?, name?, text?, variant?, color?, size?, rounded?, square?, tooltip?}

Avatar:Brand:

Prop Type Default Description
image string? null Image URL of the mark, set as an inline background-image style and scaled to the mark (bg-cover)

Other attributes go to the <span class="avatar-brand">. A style attribute is merged after the background-image, so it can still override it.

Avatar:Upload:

Prop Type Default Description
href string? null Renders an <a href>; without it, a <button type="button">
size string 'md' xxs xs sm md lg xl 2xl
icon string? null Tabler icon or UX Icons name, rendered with Icon
text string? null Label under the icon (avatar-upload-text)
Component Renders
Avatar:List <div class="avatar-list">: a row of avatars
Avatar:Brand <span class="avatar-brand">: a mark in the bottom corner of an avatar
Avatar:Upload <button class="avatar avatar-upload"> (or <a>): an empty slot
Block Default
content The initials of name without an image; the children (initials, an icon) replace them

The content block of Avatar:List renders an Avatar for each entry of items; the children replace it. Avatar:Brand has an empty content block for its children. The content block of Avatar:Upload renders the icon and the text.