3D Pressable Button Using Perspective Transform

Design an interactive 3D pressable button with CSS-only perspective and transform effects to simulate depth when clicked.

Why this works

By combining CSS perspective and transform effects, the button appears to press inward, enhancing the tactile feel without requiring JavaScript or heavy animations.

Source Code

<button class="pressable-button" onclick="noop()">Press Me</button>

<style>
.pressable-button {
  background-color: #0d6efd;
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.25rem;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  transform-style: preserve-3d;
  perspective: 1000px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.pressable-button:active {
  transform: scale(0.95) rotateX(10deg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
</style>