# Play Pause Button

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

- Category: [CSS Buttons](https://copy-css.com/category/buttons)
- Tags: media, audio, video, clip-path, morph, toggle
- Live preview: https://copy-css.com/snippets/play-pause-button
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<label class="btn-play">
  <input type="checkbox" aria-label="Play">
  <span class="btn-play-icon" aria-hidden="true"></span>
</label>
```

## CSS

```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; }
}
```

## Notes

- 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.
- the :has() selector: Chrome 105+, Safari 15.4+, Firefox 121+.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
