mirror of
https://github.com/tabler/tabler.git
synced 2026-10-20 23:04:20 +04:00
101 lines
6.4 KiB
Plaintext
101 lines
6.4 KiB
Plaintext
---
|
||
title: Avatar
|
||
summary: An avatar helps customize interface elements and make the product experience more personalized. It is often used in communication apps, collaboration tools, and social media.
|
||
description: Personalize UI with a user avatar.
|
||
layout: '@layouts/DocsMdxLayout.astro'
|
||
---
|
||
import Example from '@components/Example.astro';
|
||
import Icon from '@ui/Icon.astro';
|
||
import AvatarList from '@ui/AvatarList.astro';
|
||
import CodeDocs from '@components/CodeDocs.astro';
|
||
|
||
## Default markup
|
||
|
||
Use the `avatar` class to add an avatar to your interface design for greater customization.
|
||
|
||
<Example centered>
|
||
<span class="avatar" style="background-image: url(/static/avatars/002f.jpg)"></span> <span class="avatar">JL</span> <span class="avatar" style="background-image: url(/static/avatars/004f.jpg)"></span>
|
||
</Example>
|
||
|
||
## Avatar image
|
||
|
||
Set an image as the background to make users easy to indentify and create a personalized experience.
|
||
|
||
<Example centered>
|
||
<span class="avatar" style="background-image: url(/static/avatars/016f.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/022m.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/036m.jpg)"></span>
|
||
</Example>
|
||
|
||
## Initials
|
||
|
||
You can also use initials instead of pictures.
|
||
|
||
<Example centered>
|
||
<span class="avatar">AB</span> <span class="avatar">CD</span> <span class="avatar">EF</span> <span class="avatar">GH</span> <span class="avatar">IJ</span>
|
||
</Example>
|
||
|
||
## Avatar icons
|
||
|
||
Besides pictures and initials, you can also use icons to make the avatars more universal.
|
||
|
||
<Example centered>
|
||
<span class="avatar"> <Icon name="user" /> </span> <span class="avatar"> <Icon name="plus" /> </span> <span class="avatar"> <Icon name="settings" /> </span>
|
||
</Example>
|
||
|
||
## Avatar initials color
|
||
|
||
Customize the color of the avatars' background. See the [full list of available colors](/ui/base/colors) for more details.
|
||
|
||
<Example centered>
|
||
<span class="avatar bg-green-lt">AB</span> <span class="avatar bg-red-lt">CD</span> <span class="avatar bg-yellow-lt">EF</span> <span class="avatar bg-primary-lt">GH</span> <span class="avatar bg-purple-lt">IJ</span>
|
||
</Example>
|
||
|
||
## Avatar size
|
||
|
||
Using Bootstrap’s typical naming structure, you can create a standard avatar or scale it up or down to different sizes based on what you need.
|
||
|
||
<Example centered>
|
||
<span class="avatar avatar-xl" style="background-image: url(/static/avatars/000m.jpg)"></span> <span class="avatar avatar-lg" style="background-image: url(/static/avatars/000m.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/000m.jpg)"></span> <span class="avatar avatar-sm" style="background-image: url(/static/avatars/000m.jpg)"></span> <span class="avatar avatar-xs" style="background-image: url(/static/avatars/000m.jpg)"></span>
|
||
</Example>
|
||
|
||
## Avatar status
|
||
|
||
Add a status indicator to your avatar to show, for instance, if a user is online or offline or indicate the number of messages they have received.
|
||
|
||
<Example centered>
|
||
<span class="avatar" style="background-image: url(/static/avatars/018m.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/015m.jpg)"> <span class="badge bg-danger"></span> </span> <span class="avatar" style="background-image: url(/static/avatars/022m.jpg)"> <span class="badge bg-success"></span> </span> <span class="avatar"> <span class="badge bg-warning"></span>SA </span> <span class="avatar" style="background-image: url(/static/avatars/022m.jpg)"> <span class="badge bg-info"></span> </span> <span class="avatar" style="background-image: url(/static/avatars/048m.jpg)"> <span class="badge bg-gray">5</span> </span>
|
||
</Example>
|
||
|
||
## Avatar shape
|
||
|
||
Change the shape of an avatar with the default Bootstrap image classes. You can make them round or square and change their border radius.
|
||
|
||
<Example centered>
|
||
<span class="avatar" style="background-image: url(/static/avatars/019m.jpg)"></span> <span class="avatar rounded" style="background-image: url(/static/avatars/039f.jpg)"></span> <span class="avatar rounded-circle">AA</span> <span class="avatar rounded-0" style="background-image: url(/static/avatars/043f.jpg)"></span> <span class="avatar rounded-3" style="background-image: url(/static/avatars/044f.jpg)"></span>
|
||
</Example>
|
||
|
||
## Avatars list
|
||
|
||
Create a list of avatars within one parent container.
|
||
|
||
<Example centered>
|
||
<AvatarList> <span class="avatar rounded" style="background-image: url(/static/avatars/031f.jpg)"></span> <span class="avatar rounded">JL</span> <span class="avatar rounded" style="background-image: url(/static/avatars/033f.jpg)"></span> <span class="avatar rounded" style="background-image: url(/static/avatars/017m.jpg)"></span> <span class="avatar rounded" style="background-image: url(/static/avatars/024m.jpg)"></span> </AvatarList>
|
||
</Example>
|
||
|
||
## Stacked list
|
||
|
||
Make the list stack once a certain number of avatars is reached to make it look clear and display well regardless of the screen size.
|
||
|
||
<Example centered>
|
||
<AvatarList stacked={true}> <span class="avatar">EB</span> <span class="avatar" style="background-image: url(/static/avatars/026m.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/016f.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/028m.jpg)"></span> <span class="avatar" style="background-image: url(/static/avatars/030m.jpg)"></span> <span class="avatar">+8</span> </AvatarList>
|
||
</Example>
|
||
|
||
<Example centered>
|
||
<AvatarList stacked={true}> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/035m.jpg)" ></span> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/027f.jpg)" ></span> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/036f.jpg)" ></span> <span class="avatar avatar-sm rounded-circle">SA</span> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/034f.jpg)" ></span> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/043f.jpg)" ></span> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/039f.jpg)" ></span> <span class="avatar avatar-sm rounded-circle" style="background-image: url(/static/avatars/020m.jpg)" ></span> </AvatarList>
|
||
</Example>
|
||
|
||
## SCSS variables
|
||
|
||
Use these SCSS variables to customize avatars. The default values are:
|
||
|
||
<CodeDocs name="avatar-variables" file="core/scss/_variables.scss" />
|