Avatars are used to quickly identify users or teams.
Classes
Section titled Classes| Class | Parent | Modifies | Description |
|---|---|---|---|
.s-avatar
|
N/A | N/A | The base avatar at 16px. |
.s-avatar--image
|
.s-avatar
|
N/A | A child element for displaying a user’s profile image. |
.s-avatar--letter
|
.s-avatar
|
N/A | A child element for displaying an abbreviated Team name. |
.s-avatar--badge
|
.s-avatar
|
N/A | A child element that provides positioning to the shield on Team avatars. |
.s-avatar--indicator
|
.s-avatar
|
N/A | A child element that provides positioning to the activity indicator on user's avatars. |
.s-avatar__24
|
N/A |
.s-avatar
|
Adds the proper border radius and scaling at 24px. |
.s-avatar__32
|
N/A |
.s-avatar
|
Adds the proper border radius and scaling at 32px. |
.s-avatar__48
|
N/A |
.s-avatar
|
Adds the proper border radius and scaling at 48px. |
.s-avatar__64
|
N/A |
.s-avatar
|
Adds the proper border radius and scaling at 64px. |
.s-avatar__96
|
N/A |
.s-avatar
|
Adds the proper border radius and scaling at 96px. |
.s-avatar__128
|
N/A |
.s-avatar
|
Adds the proper border radius and scaling at 128px. |
Examples
Section titled ExamplesUsers
Section titled UsersIncluding an image with the class s-avatar--image within s-avatar will apply the correct size. Remember, you’ll want to double the size of the avatar image to account for retina screens.
<a href="…" class="s-avatar">
<img class="s-avatar--image" src="https://picsum.photos/32" />
</a>
<a href="…" class="s-avatar s-avatar__24">
<img class="s-avatar--image" src="https://picsum.photos/48" />
</a>
<a href="…" class="s-avatar s-avatar__32">
<img class="s-avatar--image" src="https://picsum.photos/64" />
</a>
<a href="…" class="s-avatar s-avatar__48">
<img class="s-avatar--image" src="https://picsum.photos/96" />
</a>
<a href="…" class="s-avatar s-avatar__64">
<img class="s-avatar--image" src="https://picsum.photos/128" />
</a>
<a href="…" class="s-avatar s-avatar__96">
<img class="s-avatar--image" src="https://picsum.photos/192" />
</a>
<a href="…" class="s-avatar s-avatar__128">
<img class="s-avatar--image" src="https://picsum.photos/256" />
</a>
Activity
Section titled Activity
Avatars can display activity indicators to show activities or status changes.
Add the s-avatar--indicator class to a child element of s-avatar along with s-activity-indicator and s-activity-indicator__sm classes.
The indicator is positioned at the top-right corner of the avatar.
<a href="…" class="s-avatar">
<div class="s-avatar--indicator s-activity-indicator s-activity-indicator__sm s-activity-indicator__success">
<div class="v-visible-sr">Online</div>
</div>
<img class="s-avatar--image" src="https://picsum.photos/32" />
</a>
<a href="…" class="s-avatar s-avatar__24">
<div class="s-avatar--indicator s-activity-indicator s-activity-indicator__sm s-activity-indicator__success">
<div class="v-visible-sr">Online</div>
</div>
<img class="s-avatar--image" src="https://picsum.photos/48" />
</a>
Stack Internal
Section titled Stack InternalWhen displaying a team’s identity, we badge the avatar with a shield. We fall back to the first letter of their name and a color we choose at random. As Stack Internal administrators add more data—choosing a color or uploading an avatar—we progressively enhance the avatar.
In this example, from left to right, we have a team name of Hum with no avatar or custom color. In the middle we have a team name of Hum with a custom color. In the last example, we have a team name of Hum with a custom avatar applied.
<a href="…" class="s-link s-link__muted">
<div class="s-avatar">
<div class="s-avatar--letter" aria-hidden="true">H</div>
@Svg.ShieldXSm.With("native s-avatar--badge")
</div>
<span class="pl4">Team name</span>
</a>
<a href="…" class="s-avatar s-avatar__24">
<div class="s-avatar--letter" aria-hidden="true">H</div>
<span class="v-visible-sr">Hum</span>
@Svg.ShieldXSm.With("native s-avatar--badge")
</a>
<a href="…" class="s-avatar s-avatar__32">
<div class="s-avatar--letter" aria-hidden="true">H</div>
<span class="v-visible-sr">Hum</span>
@Svg.ShieldXSm.With("native s-avatar--badge")
</a>
<a href="…" class="s-avatar s-avatar__48">
<div class="s-avatar--letter" aria-hidden="true">H</div>
<span class="v-visible-sr">Hum</span>
@Svg.ShieldXSm.With("native s-avatar--badge")
</a>
<a href="…" class="s-avatar s-avatar__64">
<div class="s-avatar--letter" aria-hidden="true">H</div>
<span class="v-visible-sr">Hum</span>
@Svg.ShieldXSm.With("native s-avatar--badge")
</a>
<a href="…" class="s-avatar s-avatar__96">
<div class="s-avatar--letter" aria-hidden="true">H</div>
<span class="v-visible-sr">Hum</span>
@Svg.ShieldXSm.With("native s-avatar--badge")
</a>
<a href="…" class="s-avatar s-avatar__128">
<div class="s-avatar--letter" aria-hidden="true">H</div>
<span class="v-visible-sr">Hum</span>
@Svg.ShieldXSm.With("native s-avatar--badge")
</a>