아바타 그룹

Avatar group

여러 사용자를 좁은 가로 폭에 겹쳐 쌓고, 다 들어가지 않는 나머지는 "+2"처럼 숫자로 묶어 보여주는 패턴.

다른 이름: Stacked avatarsFacepile
···
html
<div class="agw">
  <div class="aglist" id="aglist" role="group" aria-label="참여자 5명">
    <span class="agitem" style="background:#5b5bf7" title="정경훈">정</span>
    <span class="agitem" style="background:#f25c8a" title="김서연">김</span>
    <span class="agitem" style="background:#18c29c" title="박도윤">박</span>
    <button class="agmore" aria-haspopup="dialog" aria-label="나머지 2명 더 보기">+2</button>
  </div>
  <div class="agcallout" id="agcallout"></div>
</div>
css
.agw{position:absolute;inset:0;display:grid;place-items:center;gap:14px}
.aglist{display:flex}
.agitem{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:11px;font-weight:700;border:2px solid var(--bg);margin-left:-9px;transition:transform .25s}
.agitem:first-child{margin-left:0}
.agitem[data-lift]{transform:translateY(-6px)}
.agmore{width:30px;height:30px;border-radius:50%;background:var(--line);color:var(--fg);font-size:10px;font-weight:700;border:2px solid var(--bg);margin-left:-9px;cursor:default}
.agcallout{font-size:10px;color:var(--muted);height:12px}
js
const items = [...document.querySelectorAll('.agitem')];
const callout = document.getElementById('agcallout');
let auto = true, i = 0;
function paint() {
  items.forEach((it, idx) => it.toggleAttribute('data-lift', idx === i));
  callout.textContent = items[i].getAttribute('title');
}
items.forEach((it) => it.addEventListener('mouseenter', () => { auto = false; }));
paint();
setInterval(() => { if (!auto) return; i = (i + 1) % items.length; paint(); }, 900);

문서 공동 편집자, 화상통화 참여자, 담당자 목록처럼 "누가 관여하고 있나"를 한눈에 요약할 때 씁니다. 이 사전의 "아바타" 항목이 사진 로딩 실패 폴백처럼 아바타 하나 자체를 다루는 반면, 이 항목은 여러 아바타를 하나의 묶음으로 배치하는 구성 패턴에 집중합니다.

겹쳐진 원 안에는 이름을 넣을 자리가 없으므로, 각 아바타의 접근 가능한 이름은 시각적 텍스트가 아니라 title이나 aria-label로 보충해야 합니다. 마우스를 올리면 이름이 뜨는 정도로 충분하지만, 터치 기기에는 호버가 없으니 "+2" 같은 나머지 인원 버튼을 눌러 전체 이름 목록을 볼 수 있는 경로도 함께 둡니다.

순서는 보통 마지막에 참여한 사람이 맨 앞(또는 맨 뒤)에 오도록 규칙을 정해두면, 매번 다른 순서로 흔들리는 것보다 위치가 안정적으로 느껴집니다.