토스트

Toast

화면 한쪽 구석에 잠깐 나타났다 몇 초 뒤 스스로 사라지는 짧은 상태 메시지.

다른 이름: SnackbarNotificationToast notification
···
html
<div class="app-bg"><div class="bar" style="width:65%"></div><div class="bar" style="width:44%"></div><div class="bar" style="width:80%"></div></div>
<div class="toast" id="tst" role="status" aria-live="polite"><span class="dot"></span>저장되었습니다</div>
css
.app-bg{position:absolute;inset:0;padding:16px;display:grid;gap:10px;align-content:start}
.bar{height:10px;border-radius:5px;background:var(--line)}
.toast{position:absolute;left:50%;bottom:16px;transform:translate(-50%,140%);display:flex;align-items:center;gap:8px;
  background:var(--fg);color:var(--bg);padding:9px 16px;border-radius:999px;font-size:12px;font-weight:600;
  box-shadow:0 10px 26px rgba(0,0,0,.28);transition:transform .32s cubic-bezier(.2,.9,.3,1.2)}
.toast[data-open]{transform:translate(-50%,0)}
.dot{width:7px;height:7px;border-radius:50%;background:var(--accent-3, #18c29c)}
js
const t = document.getElementById('tst');
function loop() {
  t.setAttribute('data-open', '');
  setTimeout(() => { t.removeAttribute('data-open'); setTimeout(loop, 900); }, 2200);
}
loop();

방금 한 행동의 결과("저장됨", "전송 실패")를 알릴 때 씁니다. role="status" aria-live="polite"로 만들면 스크린리더가 지금 읽던 내용을 끊지 않고 짬을 봐서 읽어주고, 오류처럼 즉시 알려야 하면 aria-live="assertive"를 씁니다.

배너와 혼동하기 쉽습니다. 배너는 페이지 상단에 고정돼 사용자가 직접 닫기 전까지 남아있는 공지("서비스 점검 예정")이고, 토스트는 몇 초 안에 자동으로 사라지는 일회성 피드백입니다. 배너를 토스트처럼 몇 초 만에 없애면 사용자가 읽기도 전에 사라지고, 토스트를 배너처럼 계속 띄워두면 화면을 가립니다.

자동으로 사라지는 시간은 최소 5초 이상을 권장합니다(WCAG). 여러 개가 쌓이면 위로 밀려 올라가는 스택으로 처리합니다.