<div class="wf-stack-group">
<div class="wf-stack-item"><img src="avatar1.jpg" alt="User 1"></div>
<div class="wf-stack-item"><img src="avatar2.jpg" alt="User 2"></div>
<div class="wf-stack-item"><img src="avatar3.jpg" alt="User 3"></div>
</div>
Stacks
Pure-CSS avatar stack for displaying overlapping circular images or initials badges. Compose size presets, overlap densities, directions, hover animations, ring borders, and a +N counter badge entirely through CSS classes.
Quick Start
Wrap items in div.wf-stack-group and give each child the class wf-stack-item . Place an <img> inside each item — it fills the circle with object-fit: cover automatically.
Sizes
Add a size class to wf-stack-group to set the --wf-stack-size CSS variable for all child items. The default (no class) is wf-stack-md at 2.75rem.
xs · 1.75rem
sm · 2.25rem
md · 2.75rem (default)
lg · 3.5rem
xl · 4.5rem
<div class="wf-stack-group wf-stack-xs">...</div> <!-- 1.75rem -->
<div class="wf-stack-group wf-stack-sm">...</div> <!-- 2.25rem -->
<div class="wf-stack-group wf-stack-md">...</div> <!-- 2.75rem (default) -->
<div class="wf-stack-group wf-stack-lg">...</div> <!-- 3.5rem -->
<div class="wf-stack-group wf-stack-xl">...</div> <!-- 4.5rem -->
<!-- Custom size via CSS variable -->
<div class="wf-stack-group" style="--wf-stack-size: 5rem">...</div>
Overlap
Three overlap presets control how much each item covers its neighbor by adjusting a negative margin-inline-start . The default (no class) matches wf-stack-tight . You can also set --wf-gap directly for a custom value.
wf-stack-tight
wf-stack-normal
wf-stack-loose
<div class="wf-stack-group wf-stack-tight">...</div> <!-- items nearly touch -->
<div class="wf-stack-group wf-stack-normal">...</div> <!-- medium overlap -->
<div class="wf-stack-group wf-stack-loose">...</div> <!-- widely spaced -->
<!-- Custom overlap via CSS variable -->
<div class="wf-stack-group" style="--wf-gap: -0.5rem">...</div>
Direction
By default, items overlap left-to-right (first item on top). Use wf-stack-reverse to flip the order so items overlap right-to-left. Use wf-stack-vertical for a column with top overlap.
Default (left-to-right)
wf-stack-reverse
wf-stack-vertical
<!-- Right-to-left overlap -->
<div class="wf-stack-group wf-stack-reverse">...</div>
<!-- Vertical column with top overlap -->
<div class="wf-stack-group wf-stack-vertical">...</div>
Hover Lift
Add wf-stack-hover to the group to make each item rise ( translateY(-3px) ) with a spring animation when hovered. The hovered item also gets a higher z-index so it appears above its neighbors.
<div class="wf-stack-group wf-stack-hover">
<div class="wf-stack-item"><img src="avatar.jpg" alt="..."></div>
<div class="wf-stack-item wf-stack-label wf-bg-secondary">AL</div>
</div>
Organic Lift
wf-stack-lift staggers the group into a gentle wave: odd-indexed items translate up 3px and even-indexed items translate down 3px , creating an organic hand-placed look.
<div class="wf-stack-group wf-stack-lift">
<div class="wf-stack-item"><img src="avatar.jpg" alt="..."></div>
<div class="wf-stack-item"><img src="avatar.jpg" alt="..."></div>
<div class="wf-stack-item"><img src="avatar.jpg" alt="..."></div>
</div>
Ring
wf-stack-ring adds a 2px white ring around every item using box-shadow . This separates overlapping items visually and works well on light backgrounds. For dark or transparent backgrounds use the wf-stack-item-transparent modifier on individual items to switch the ring to a translucent white.
Without ring
wf-stack-ring
<!-- White ring on every item -->
<div class="wf-stack-group wf-stack-ring">...</div>
<!-- Translucent ring for dark/transparent backgrounds -->
<div class="wf-stack-group wf-stack-ring">
<div class="wf-stack-item wf-stack-item-transparent">...</div>
<div class="wf-stack-item wf-stack-item-transparent">...</div>
</div>
Shadow
wf-stack-shadow applies a soft drop shadow to every item. Combine it with wf-stack-ring for a more polished look, or use it alone for a floating effect.
wf-stack-shadow
wf-stack-ring + wf-stack-shadow
<div class="wf-stack-group wf-stack-shadow">...</div>
<!-- Combined with ring -->
<div class="wf-stack-group wf-stack-ring wf-stack-shadow">...</div>
Counter Badge
Add a +N overflow count as the last child. Give it both wf-stack-item (for the circular shape and sizing) and wf-stack-counter (for the small bold typography). Supply a background color using a framework color utility or custom style.
<div class="wf-stack-group wf-stack-ring">
<div class="wf-stack-item"><img src="avatar1.jpg" alt="User 1"></div>
<div class="wf-stack-item"><img src="avatar2.jpg" alt="User 2"></div>
<div class="wf-stack-item"><img src="avatar3.jpg" alt="User 3"></div>
<div class="wf-stack-item wf-stack-counter" style="background: var(--wf-surface-2)">+24</div>
</div>
Class Reference
wf-stack-responsive reduces the item size to 2.25rem on viewports narrower than 42rem . Add it to the group alongside any size preset.
| Class | Applied to | Description |
|---|---|---|
wf-stack-group |
Container | Inline-flex row container. Sets --wf-stack-size: 2.75rem for all children. All modifier classes go on this element. |
wf-stack-item |
Child | Circular item — fixed square size from --wf-stack-size, border-radius: 999rem, overflow: hidden. Place an <img> or text inside.
|
wf-stack-xs |
Group | Sets --wf-stack-size: 1.75rem. |
wf-stack-sm |
Group | Sets --wf-stack-size: 2.25rem. |
wf-stack-md |
Group | Sets --wf-stack-size: 2.75rem (matches the default). |
wf-stack-lg |
Group | Sets --wf-stack-size: 3.5rem. |
wf-stack-xl |
Group | Sets --wf-stack-size: 4.5rem. |
wf-stack-tight |
Group | Tighter negative overlap — items nearly touch. Uses --wf-space-2. |
wf-stack-normal |
Group | Medium overlap. Uses --wf-space-4. |
wf-stack-loose |
Group | Wider spacing. Uses --wf-space-6. |
wf-stack-reverse |
Group | Flips to flex-direction: row-reverse so items overlap right-to-left. |
wf-stack-vertical |
Group | Column direction with negative top margin creating a vertical overlap. |
wf-stack-hover |
Group | Hovered items lift translateY(-3px) with a spring easing. Hovered item rises above neighbors via z-index. |
wf-stack-lift |
Group | Organic wave — odd children shift up 3px, even children shift down 3px. |
wf-stack-ring |
Group | Adds a 2px white box-shadow ring around every item to visually separate overlapping circles. |
wf-stack-item-transparent |
Item | Modifier for use inside wf-stack-ring. Replaces the white ring with a translucent white ring, suitable for dark or image backgrounds. |
wf-stack-shadow |
Group | Applies a soft drop shadow to every item. |
wf-stack-counter |
Item | Typography preset for a +N overflow badge — 0.75rem font size, medium weight, line-height: 1. Apply alongside wf-stack-item. |
wf-stack-responsive |
Group | Shrinks --wf-stack-size to 2.25rem on viewports narrower than 42rem.
|