43 CSS Button Designs

Confirm Delete

A two-step destructive pattern: the first click shakes the button and slides up a red confirmation panel; a second click within three seconds wipes it with a sweep into a "Deleted" ghost state.

CSS + JS MIT licensed

Confirm Delete the 4th of 43 designs in the 43 CSS Button Designs collection. The design pairs CSS styling with a small amount of JavaScript for interactivity. Copy the HTML, CSS and JavaScript panels below into your project — the JS is self-contained, has zero dependencies, and is safe to drop into any framework (React, Vue, Svelte, plain HTML). The design honours prefers-reduced-motion and uses real semantic markup, so it ships accessibility-ready out of the box.

Live preview

Open in playground

The code

<button class="btn-del">
  <span class="btn-del-icon" aria-hidden="true">🗑</span>
  <span class="btn-del-text">Delete Item</span>
  <span class="btn-del-confirm">⚠ Tap again to confirm</span>
  <span class="btn-del-wipe" aria-hidden="true"></span>
</button>
.btn-del {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 170px;
  padding: 13px 22px;
  border: 1.5px solid #fca5a5;
  border-radius: 10px;
  background: #fff0f0;
  color: #dc2626;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  transition: background 0.3s, border-color 0.3s;
}
.btn-del:hover { background: #fee2e2; border-color: #f87171; }
.btn-del-icon { font-size: 16px; }
.btn-del-text { transition: opacity 0.2s; }
.btn-del-confirm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #dc2626;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.25s, transform 0.25s cubic-bezier(.22,1,.36,1);
}
.btn-del-wipe {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #dc2626;
  border-radius: 8px;
  transform: scaleX(0);
  transform-origin: left;
}
.btn-del.is-confirming { animation: btn-del-shake 0.4s cubic-bezier(.36,.07,.19,.97); }
.btn-del.is-confirming .btn-del-confirm { opacity: 1; transform: translateY(0); }
.btn-del.is-confirming .btn-del-text,
.btn-del.is-confirming .btn-del-icon { opacity: 0; }
@keyframes btn-del-shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-1deg); }
  40% { transform: translateX(5px) rotate(1deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.btn-del.is-deleting { pointer-events: none; overflow: visible; }
.btn-del.is-deleting .btn-del-wipe { animation: btn-del-wipe-out 0.5s cubic-bezier(.77,0,.18,1) forwards; }
@keyframes btn-del-wipe-out {
  0%   { transform: scaleX(0); opacity: 1; }
  60%  { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
.btn-del.is-deleted {
  border-color: #e5e7eb;
  background: #f9fafb;
  color: #9ca3af;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .btn-del.is-confirming { animation: none; }
  .btn-del.is-deleting .btn-del-wipe { animation: none; }
}
document.querySelectorAll('.btn-del').forEach(function (btn) {
  var state = 'idle';
  var resetTimer;
  btn.addEventListener('click', function () {
    if (state === 'idle') {
      state = 'confirming';
      btn.classList.add('is-confirming');
      resetTimer = setTimeout(function () {
        if (state === 'confirming') {
          state = 'idle';
          btn.classList.remove('is-confirming');
        }
      }, 3000);
    } else if (state === 'confirming') {
      clearTimeout(resetTimer);
      state = 'deleting';
      btn.classList.add('is-deleting');
      setTimeout(function () {
        btn.classList.remove('is-confirming', 'is-deleting');
        btn.classList.add('is-deleted');
        btn.querySelector('.btn-del-icon').textContent = '✓';
        btn.querySelector('.btn-del-icon').style.opacity = '1';
        btn.querySelector('.btn-del-text').textContent = 'Deleted';
        btn.querySelector('.btn-del-text').style.opacity = '1';
        btn.querySelector('.btn-del-confirm').style.opacity = '0';
      }, 600);
    }
  });
});

Search CodeFronts

Loading…