CSS Play Pause Button

A round media button whose play triangle morphs into pause bars when toggled, built on a checkbox.

  • media
  • audio
  • video
  • clip-path
  • morph
  • toggle
HTML
<label class="btn-play">
  <input type="checkbox" aria-label="Play">
  <span class="btn-play-icon" aria-hidden="true"></span>
</label>
CSS
.btn-play {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #18181b;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.btn-play input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.btn-play-icon {
  position: relative;
  width: 22px;
  height: 24px;
  margin-left: 4px;
  pointer-events: none;
  transition: margin 0.25s ease;
}

/* Two halves of a triangle that become two bars */
.btn-play-icon::before,
.btn-play-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  transition: clip-path 0.25s ease;
}

.btn-play-icon::before {
  clip-path: polygon(0 0, 50% 25%, 50% 75%, 0 100%);
}

.btn-play-icon::after {
  clip-path: polygon(50% 25%, 100% 50%, 100% 50%, 50% 75%);
}

.btn-play input:checked + .btn-play-icon {
  margin-left: 0;
}

.btn-play input:checked + .btn-play-icon::before {
  clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%);
}

.btn-play input:checked + .btn-play-icon::after {
  clip-path: polygon(65% 0, 100% 0, 100% 100%, 65% 100%);
}

.btn-play:active {
  transform: scale(0.94);
}

.btn-play:has(input:focus-visible) {
  outline: 3px solid #18181b;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .btn-play-icon::before,
  .btn-play-icon::after { transition: none; }
}

About this CSS Play Pause Button

This CSS Play Pause Button is 73 lines of pure CSS (1.4 KB) with no JavaScript and no dependencies. It uses transitions, transforms, clip paths and CSS Grid. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #18181b
  • #fff

How to use this play pause button

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .btn-play class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback