{
  "id": "play-pause-button",
  "name": "Play Pause Button",
  "category": "buttons",
  "tags": [
    "media",
    "audio",
    "video",
    "clip-path",
    "morph",
    "toggle"
  ],
  "description": "A round media button whose play triangle morphs into pause bars when toggled, built on a checkbox.",
  "url": "https://copy-css.com/snippets/play-pause-button",
  "markdown": "https://copy-css.com/snippets/play-pause-button.md",
  "html": "<label class=\"btn-play\">\n  <input type=\"checkbox\" aria-label=\"Play\">\n  <span class=\"btn-play-icon\" aria-hidden=\"true\"></span>\n</label>",
  "css": ".btn-play {\n  position: relative;\n  display: inline-grid;\n  place-items: center;\n  width: 64px;\n  height: 64px;\n  border-radius: 50%;\n  background: #18181b;\n  color: #fff;\n  cursor: pointer;\n  transition: transform 0.15s ease;\n}\n\n.btn-play input {\n  position: absolute;\n  inset: 0;\n  margin: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n\n.btn-play-icon {\n  position: relative;\n  width: 22px;\n  height: 24px;\n  margin-left: 4px;\n  pointer-events: none;\n  transition: margin 0.25s ease;\n}\n\n/* Two halves of a triangle that become two bars */\n.btn-play-icon::before,\n.btn-play-icon::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background: currentColor;\n  transition: clip-path 0.25s ease;\n}\n\n.btn-play-icon::before {\n  clip-path: polygon(0 0, 50% 25%, 50% 75%, 0 100%);\n}\n\n.btn-play-icon::after {\n  clip-path: polygon(50% 25%, 100% 50%, 100% 50%, 50% 75%);\n}\n\n.btn-play input:checked + .btn-play-icon {\n  margin-left: 0;\n}\n\n.btn-play input:checked + .btn-play-icon::before {\n  clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%);\n}\n\n.btn-play input:checked + .btn-play-icon::after {\n  clip-path: polygon(65% 0, 100% 0, 100% 100%, 65% 100%);\n}\n\n.btn-play:active {\n  transform: scale(0.94);\n}\n\n.btn-play:has(input:focus-visible) {\n  outline: 3px solid #18181b;\n  outline-offset: 3px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .btn-play-icon::before,\n  .btn-play-icon::after { transition: none; }\n}",
  "features": [
    "transitions",
    "transforms",
    "clip paths",
    "CSS Grid",
    "the :has() selector",
    "the :checked state (no JavaScript)",
    "keyboard focus styles",
    "reduced-motion support"
  ],
  "customProperties": []
}
