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

불러오는 중…

최근 방문

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

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

확인 대화상자Confirmation dialog

되돌릴 수 없는 일을 하기 전에 화면 가운데에서 한 번 더 묻는 창이에요. 무엇이 사라지는지 구체적으로 보여 주고, 실수로 누르기 쉬운 쪽은 안전한 선택으로 둬요.

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

이럴 때 써요

  • 계정 삭제, 결제, 전체 초기화처럼 되돌릴 수 없는 일 바로 전
  • 잃는 것이 큰 일(저장 안 한 글을 버리고 나가기 등)
  • 사용자가 꼭 읽고 골라야 하는 순간

이럴 땐 다른 걸 써요

  • 되돌릴 수 있으면 → 바로 하고 실행 취소 스낵바(확인 창을 자주 띄우면 아무도 안 읽어요)
  • 단순한 안내라면 → 인라인 알림

무엇으로 이루어지나

  • 뒤 배경 어둡게(50%)
  • 질문형 제목("계정을 지울까요?")
  • 잃는 것을 숫자로 적은 설명
  • 안전한 단추(취소)와 위험한 단추(빨강, 동사로 "지우기")

잘 만드는 요령

  1. 위험한 단추 글자는 "확인" 대신 "지우기", "결제하기"처럼 할 일을 그대로 적어요. 읽지 않고 눌러도 무슨 일인지 알 수 있어요.
  2. 창이 열리면 처음 포커스는 "취소"에 둬요. 엔터를 습관처럼 눌러도 아무것도 사라지지 않아요.
  3. 열릴 때 250ms 동안 살짝 크게(1.05배) 시작해 제자리로 오고, 닫힐 때는 100ms 로 빨리 사라지게 하면 무겁지 않아요.
  4. HTML 의 <dialog> 와 showModal() 을 쓰면 Esc 로 닫기, 뒤쪽 클릭 막기, 포커스 가두기가 기본으로 돼요.

AI 에게 시키는 프롬프트

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

"계정 삭제…" 단추를 누르면 확인 대화상자가 뜨는 화면을 만들어 줘. <dialog> 와 showModal() 을 쓰고, 제목 "계정을 지울까요?", 설명 "저장한 도구 14개와 메모가 모두 사라지고 되돌릴 수 없어요.", 오른쪽 아래에 "취소"(회색)와 "지우기"(빨강) 단추. 열리면 포커스는 취소에. 열릴 때 창은 scale 1.05→1, 투명도 0→1 로 250ms, 뒤 배경(검정 50%)은 150ms 로 나타나. 닫힐 때는 100ms 로 사라져. Esc 나 뒤 배경 클릭도 취소로 처리하고, 고른 결과를 단추 아래 한 줄로 보여 줘. 창 모서리 24px. 조건: 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}}

/* 확인 대화상자 */
.center{display:grid;justify-items:center;gap:12px}
.result{margin:0;min-height:21px;color:var(--muted);font-size:14px}
dialog{width:min(400px,calc(100vw - 32px));padding:24px;border:0;border-radius:24px;background:var(--surface);color:var(--fg);box-shadow:var(--shadow-float)}
dialog[open]{animation:dialog-in .25s cubic-bezier(.25,.46,.45,.94)}
dialog::backdrop{background:rgba(0,0,0,.5);animation:fade-in .15s ease-out}
dialog.closing{animation:dialog-out .1s ease-out forwards}
dialog.closing::backdrop{animation:fade-out .1s ease-out forwards}
dialog h2{margin:0 0 8px;font-size:18px}
dialog p{margin:0;color:var(--muted);font-size:14px;line-height:1.6}
.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:24px}
@keyframes dialog-in{from{opacity:0;transform:scale(1.05)}to{opacity:1;transform:scale(1)}}
@keyframes dialog-out{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}
@keyframes fade-in{from{opacity:0}to{opacity:1}}
@keyframes fade-out{from{opacity:1}to{opacity:0}}
</style>
</head>
<body>
<div class="center">
  <button class="btn" id="open">계정 삭제…</button>
  <p class="result" id="result" aria-live="polite"></p>
</div>
<dialog id="dialog" aria-labelledby="dialog-title" aria-describedby="dialog-desc">
  <h2 id="dialog-title">계정을 지울까요?</h2>
  <p id="dialog-desc">저장한 도구 14개와 메모가 모두 사라지고 되돌릴 수 없어요.</p>
  <div class="actions">
    <button class="btn" type="button" data-value="cancel" autofocus>취소</button>
    <button class="btn btn-danger" type="button" data-value="ok">지우기</button>
  </div>
</dialog>
<script>
const dialog = document.getElementById('dialog');
const result = document.getElementById('result');

function close(value) {
  if (!dialog.open || dialog.classList.contains('closing')) return;
  dialog.classList.add('closing');
  setTimeout(function () {
    dialog.classList.remove('closing');
    dialog.close();
    result.textContent = value === 'ok' ? '지웠어요. (데모라 실제로는 아무것도 지우지 않아요)' : '취소했어요. 아무것도 바뀌지 않았어요.';
  }, 100);
}

document.getElementById('open').addEventListener('click', function () {
  result.textContent = '';
  dialog.showModal();
  dialog.querySelector('[data-value="cancel"]').focus();
});
dialog.addEventListener('click', function (event) {
  const button = event.target.closest('[data-value]');
  if (button) close(button.dataset.value);
  else if (event.target === dialog) {
    const box = dialog.getBoundingClientRect();
    const inside = event.clientX >= box.left && event.clientX <= box.right && event.clientY >= box.top && event.clientY <= box.bottom;
    if (!inside) close('cancel');
  }
});
dialog.addEventListener('cancel', function (event) {
  event.preventDefault();
  close('cancel');
});
</script>
</body>
</html>

함께 보면 좋은 패턴

  • 실행 취소 스낵바Snackbar with undo
  • 인라인 알림Inline alert
  • 툴팁Tooltip
유틸픽 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
홈검색즐겨찾기더보기