x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!-- Default -->
<div class="avatar">
<img alt="CN" src="/assets/cartoon-93de1535.jpg" width="48" height="48" />
</div>
<!-- Button -->
<button type="button" class="btn avatar">
<img alt="CN" src="/assets/cartoon-93de1535.jpg" width="48" height="48" />
</button>
<!-- Fallback -->
<div class="avatar">
<span role="img">CN</span>
</div>
<!-- Group -->
<div class="avatar-group">
<span class="avatar"><img alt="CN" src="/assets/cartoon-93de1535.jpg" width="48" height="48" /></span>
<span class="avatar"><img alt="LN" src="/assets/lazaronixon-0f93f06b.jpg" width="48" height="48" /></span>
<span class="avatar"><img alt="EM" src="/assets/elon-09bae285.jpg" width="48" height="48" /></span>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<%# Default %>
<div class="avatar">
<%= image_tag "cartoon.jpg", size: 48, alt: "CN" %>
</div>
<%# Button %>
<button type="button" class="btn avatar">
<%= image_tag "cartoon.jpg", size: 48, alt: "CN" %>
</button>
<%# Fallback %>
<div class="avatar">
<%= tag.span "CN", role: "img" %>
</div>
<%# Group %>
<div class="avatar-group">
<span class="avatar"><%= image_tag "cartoon.jpg", size: 48, alt: "CN" %></span>
<span class="avatar"><%= image_tag "lazaronixon.jpg", size: 48, alt: "LN" %></span>
<span class="avatar"><%= image_tag "elon.jpg", size: 48, alt: "EM" %></span>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.avatar {
--radius: var(--rounded-full);
--size: var(--avatar-size, var(--size-10));
block-size: var(--size);
border-radius: var(--radius);
display: flex;
flex-shrink: 0;
inline-size: var(--size);
overflow: hidden;
&:is(.btn) {
--btn-icon-color: none;
--btn-inline-size: var(--size);
--btn-padding: 0;
--btn-radius: var(--radius);
}
&:is(.btn):hover {
filter: var(--brightness-90);
}
img {
align-content: center;
aspect-ratio: var(--aspect-square);
block-size: var(--size-full);
inline-size: var(--size-full);
object-fit: cover;
}
span[role=img] {
align-items: center;
background-color: var(--color-border-light);
block-size: var(--size-full);
border-radius: var(--radius);
display: flex;
font-size: calc(var(--size) * .4);
inline-size: var(--size-full);
justify-content: center;
user-select: none;
}
}
.avatar-group {
align-items: center;
display: flex;
> :not(:last-child) {
margin-inline-end: calc(var(--size-2) * -1);
}
}
Java Script is not required or multiple files are needed, check the notes.