본문 바로가기
UtilPick.
나의 도구함
전체 도구
즐겨찾기
즐겨찾는 도구

불러오는 중…

최근 방문

열어 본 도구가 여기에 표시돼요.

데스크톱 앱 설치
설정
UtilPick.
유틸픽게임픽디자인픽이미지픽
디자인픽 · UI 패턴 · 알림·피드백

실행 취소 스낵바Snackbar with undo

지우기 같은 일을 바로 해 버리고, 몇 초 동안 "되돌리기" 단추를 보여 주는 알림이에요. "정말 지울까요?" 를 매번 묻지 않아도 돼서 손이 빨라져요.

직접 눌러 보세요 · 아래 코드와 똑같이 움직여요

이럴 때 써요

  • 목록에서 항목 지우기, 보관함으로 옮기기처럼 되돌릴 수 있는 일
  • 자주 하는 일이라 매번 확인 창을 띄우면 귀찮을 때
  • 실수로 눌러도 몇 초 안에 바로잡을 수 있으면 충분할 때

이럴 땐 다른 걸 써요

  • 계정 삭제, 결제처럼 되돌릴 수 없는 일 → 확인 대화상자
  • 되돌릴 것 없이 결과만 알리면 → 토스트

무엇으로 이루어지나

  • 어두운 띠(화면 바탕과 반대 색이라 눈에 띔)
  • 무엇을 했는지 한 줄
  • "되돌리기" 단추 하나
  • 남은 시간 막대(선택)

잘 만드는 요령

  1. 실제 삭제는 스낵바가 사라진 뒤에 해요. 그 전까지는 화면에서만 숨겨 두면 되돌리기가 간단해요.
  2. 남은 시간을 얇은 막대로 보여 주면 "언제까지 되돌릴 수 있지?" 를 고민하지 않아요. 막대는 width 대신 scaleX 로 줄여야 매끄러워요.
  3. 단추 글자는 "실행 취소"보다 "되돌리기"처럼 결과가 보이는 말이 쉬워요.
  4. 새 일을 또 하면 이전 스낵바는 바로 확정하고 새 것으로 바꿔요. 되돌리기는 마지막 한 번만 있으면 돼요.

AI 에게 시키는 프롬프트

Claude·ChatGPT 에 붙여 넣으면 위 데모와 비슷한 화면을 HTML 파일 하나로 만들어 줘요. 글자·색은 바꿔 쓰세요.

파일 목록(3개)에서 휴지통 단추를 누르면 그 줄이 바로 사라지고, 화면 아래에 어두운 스낵바가 올라와 "'파일 이름'을 지웠어요" 와 "되돌리기" 단추를 5초 동안 보여 주는 화면을 만들어 줘. 스낵바 아래쪽에 남은 시간을 보여 주는 얇은 막대가 scaleX 1→0 으로 5초 동안 줄어들어. 되돌리기를 누르면 지운 줄이 원래 자리로 돌아와. 5초가 지나면 스낵바가 250ms 로 내려가며 사라지고 삭제가 확정돼. 다른 줄을 또 지우면 이전 것은 확정하고 스낵바 내용을 바꿔. 다 지우면 "목록이 비었어요"와 "처음으로" 단추를 보여 줘. 조건: HTML 파일 하나에 CSS·자바스크립트를 함께 넣고 외부 라이브러리는 쓰지 마. 움직임은 transform·opacity 만 쓰고, prefers-reduced-motion 이 켜져 있으면 움직임을 끄고 결과만 보여 줘. 밝은 화면과 어두운 화면(prefers-color-scheme) 둘 다 맞추고, 폰 폭 320px 에서도 깨지지 않게. 키보드로도 쓸 수 있게 하고 포커스 링이 보이게 해 줘. 강조색은 파랑(#0485F7), 글꼴은 Pretendard.

HTML 코드

위 데모를 돌리는 코드 그대로예요. 파일 하나로 저장해 브라우저로 열면 바로 움직여요. 자유롭게 고쳐 써도 돼요.

코드 펼쳐 보기
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>실행 취소 스낵바 — 유틸픽 디자인픽</title>
<style>
/* 바탕 — 밝은 화면 기본, 기기 설정이 어두우면 어두운 화면. <html class="dark"> 나 "light" 로 고정할 수 있어요. */
:root{color-scheme:light;--bg:#f7f7f8;--surface:#ffffff;--surface-2:#f0f0f2;--surface-3:#e6e6ea;--fg:#18181b;--muted:#6b6b76;--border:#e4e4e7;
  --accent:#0485f7;--accent-hover:#2b97f8;--accent-fg:#fcfcfc;--accent-soft:rgba(4,133,247,.14);--accent-soft-fg:#1e63ae;
  --success:#12a150;--success-soft:rgba(18,161,80,.14);--success-soft-fg:#0e7a3d;
  --warning:#e8930c;--warning-soft:rgba(245,165,36,.18);--warning-soft-fg:#8a5300;
  --danger:#e5484d;--danger-soft:rgba(229,72,77,.14);--danger-soft-fg:#b4232a;
  --shadow-surface:0 2px 4px rgba(0,0,0,.04),0 1px 2px rgba(0,0,0,.06),0 0 1px rgba(0,0,0,.06);
  --shadow-float:0 2px 8px rgba(0,0,0,.06),0 -6px 12px rgba(0,0,0,.03),0 14px 28px rgba(0,0,0,.08);
  --shine:rgba(255,255,255,.65);
  --ease:cubic-bezier(.32,.72,0,1);}
@media (prefers-color-scheme:dark){:root:not(.light){color-scheme:dark;--bg:#0e0e11;--surface:#1b1b20;--surface-2:#25252b;--surface-3:#303037;--fg:#fafafa;--muted:#a1a1aa;--border:#2e2e35;
  --accent:#0485f7;--accent-hover:#2b97f8;--accent-fg:#fcfcfc;--accent-soft:rgba(4,133,247,.2);--accent-soft-fg:#61a8fc;
  --success:#17c964;--success-soft:rgba(23,201,100,.16);--success-soft-fg:#5fe39a;
  --warning:#f5a524;--warning-soft:rgba(245,165,36,.16);--warning-soft-fg:#f7c26b;
  --danger:#f2555a;--danger-soft:rgba(242,85,90,.16);--danger-soft-fg:#ff8a8e;
  --shadow-surface:inset 0 0 0 1px rgba(255,255,255,.06);
  --shadow-float:inset 0 0 0 1px rgba(255,255,255,.12),0 14px 28px rgba(0,0,0,.45);
  --shine:rgba(255,255,255,.07);}}
:root.dark{color-scheme:dark;--bg:#0e0e11;--surface:#1b1b20;--surface-2:#25252b;--surface-3:#303037;--fg:#fafafa;--muted:#a1a1aa;--border:#2e2e35;
  --accent:#0485f7;--accent-hover:#2b97f8;--accent-fg:#fcfcfc;--accent-soft:rgba(4,133,247,.2);--accent-soft-fg:#61a8fc;
  --success:#17c964;--success-soft:rgba(23,201,100,.16);--success-soft-fg:#5fe39a;
  --warning:#f5a524;--warning-soft:rgba(245,165,36,.16);--warning-soft-fg:#f7c26b;
  --danger:#f2555a;--danger-soft:rgba(242,85,90,.16);--danger-soft-fg:#ff8a8e;
  --shadow-surface:inset 0 0 0 1px rgba(255,255,255,.06);
  --shadow-float:inset 0 0 0 1px rgba(255,255,255,.12),0 14px 28px rgba(0,0,0,.45);
  --shine:rgba(255,255,255,.07);}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;min-height:100vh;display:grid;place-items:center;padding:24px;background:var(--bg);color:var(--fg);
  font:15px/1.5 Pretendard,-apple-system,BlinkMacSystemFont,system-ui,'Apple SD Gothic Neo',sans-serif;-webkit-font-smoothing:antialiased;word-break:keep-all}
button{font:inherit;color:inherit}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border:0;border-radius:999px;
  background:var(--surface-2);color:var(--fg);font-size:14px;font-weight:600;cursor:pointer;
  transition:transform .25s ease,background-color .1s ease-out}
.btn:active{transform:scale(.97)}
.btn-primary{background:var(--accent);color:var(--accent-fg)}
.btn-danger{background:var(--danger);color:#fff}
@media (hover:hover){.btn:hover{background:var(--surface-3)}.btn-primary:hover{background:var(--accent-hover)}.btn-danger:hover{background:color-mix(in oklab,var(--danger) 90%,#fff)}}
.btn:disabled{opacity:.5;cursor:not-allowed;transform:none}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}

/* 실행 취소 스낵바 */
.files{width:min(360px,100%);margin:0;padding:6px;list-style:none;border-radius:20px;background:var(--surface);box-shadow:var(--shadow-surface)}
.files li{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 8px 8px 14px;border-radius:14px;font-size:14px}
.files li + li{border-top:1px solid var(--border)}
.files .empty{justify-content:center;flex-direction:column;padding:20px;color:var(--muted)}
.del{display:grid;place-items:center;width:32px;height:32px;border:0;border-radius:999px;background:transparent;color:var(--muted);cursor:pointer}
@media (hover:hover){.del:hover{background:var(--danger-soft);color:var(--danger)}}
.snack{position:fixed;left:50%;bottom:16px;width:min(380px,calc(100vw - 32px));display:flex;align-items:center;gap:12px;padding:12px 8px 12px 16px;overflow:hidden;
  border-radius:16px;background:var(--fg);color:var(--bg);font-size:14px;
  transform:translate(-50%,calc(100% + 24px));opacity:0;transition:transform .25s var(--ease),opacity .15s ease-out}
.snack.show{transform:translate(-50%,0);opacity:1;transition-duration:.35s,.15s}
.snack span{flex:1}
.undo{height:32px;padding:0 12px;border:0;border-radius:999px;background:transparent;color:var(--accent-hover);font-weight:700;cursor:pointer}
@media (hover:hover){.undo:hover{background:color-mix(in oklab,var(--bg) 14%,transparent)}}
.timer{position:absolute;left:0;right:0;bottom:0;height:3px;background:var(--accent);transform-origin:left;transform:scaleX(0)}
.timer.run{animation:countdown 5s linear forwards}
@keyframes countdown{from{transform:scaleX(1)}to{transform:scaleX(0)}}
</style>
</head>
<body>
<ul class="files" id="files">
  <li data-name="여행 사진.zip"><span>여행 사진.zip</span><button class="del" aria-label="여행 사진.zip 지우기"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7h16M9 7V4.5h6V7M6.5 7l1 13h9l1-13"/></svg></button></li>
  <li data-name="회의록.pdf"><span>회의록.pdf</span><button class="del" aria-label="회의록.pdf 지우기"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7h16M9 7V4.5h6V7M6.5 7l1 13h9l1-13"/></svg></button></li>
  <li data-name="견적서.xlsx"><span>견적서.xlsx</span><button class="del" aria-label="견적서.xlsx 지우기"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7h16M9 7V4.5h6V7M6.5 7l1 13h9l1-13"/></svg></button></li>
</ul>
<div class="snack" id="snack" role="status" aria-live="polite">
  <span id="snack-text"></span>
  <button class="undo" id="undo" tabindex="-1">되돌리기</button>
  <i class="timer" id="timer"></i>
</div>
<script>
const list = document.getElementById('files');
const snack = document.getElementById('snack');
const snackText = document.getElementById('snack-text');
const undo = document.getElementById('undo');
const timerBar = document.getElementById('timer');
const original = list.innerHTML;
let pending = null;
let timer = 0;

function finish() {
  clearTimeout(timer);
  pending = null;
  snack.classList.remove('show');
  undo.tabIndex = -1;
  if (!list.querySelector('li[data-name]')) {
    list.innerHTML = '<li class="empty">목록이 비었어요<button class="btn" id="reset">처음으로</button></li>';
  }
}

list.addEventListener('click', function (event) {
  if (event.target.closest('#reset')) { list.innerHTML = original; return; }
  const button = event.target.closest('.del');
  if (!button) return;
  if (pending) finish();
  const row = button.closest('li');
  pending = { row: row, next: row.nextElementSibling };
  row.remove();
  snackText.textContent = "'" + row.dataset.name + "'을(를) 지웠어요";
  timerBar.classList.remove('run');
  void timerBar.offsetWidth;
  timerBar.classList.add('run');
  snack.classList.add('show');
  undo.tabIndex = 0;
  timer = setTimeout(finish, 5000);
});

undo.addEventListener('click', function () {
  if (!pending) return;
  list.insertBefore(pending.row, pending.next && pending.next.isConnected ? pending.next : null);
  pending.row.querySelector('.del').focus();
  pending = null;
  finish();
});
</script>
</body>
</html>

함께 보면 좋은 패턴

  • 토스트 알림Toast
  • 확인 대화상자Confirmation dialog
  • 빈 화면 안내Empty state
유틸픽 UtilPick

복잡한 일상에, 간단한 도구 하나. 무료 온라인 유틸리티 모음.

서비스

유틸픽(UtilPick) 소개 블로그데스크톱 앱 설치

도움

도구 요청하기문제 신고하기문의info@utilpick.com

정책

개인정보처리방침이용약관
상호 조하유(JOHAU)대표 조항진사업자등록번호 365-47-00936대구광역시 달성군 유가읍 테크노대로5길 57, 210동 10층 1002호
© 2026 유틸픽 UtilPick
Featured on Twelve ToolsUtilPick - Featured on Startup FameFazier badgeFeatured on LaunchIgniter
홈검색즐겨찾기더보기