{
  "id": "follow-button",
  "name": "Follow Button",
  "category": "buttons",
  "tags": [
    "toggle",
    "checkbox",
    "following",
    "profile",
    "social"
  ],
  "description": "A Follow button that switches to an outlined Following state with a checkmark, using a checkbox.",
  "url": "https://copy-css.com/snippets/follow-button",
  "markdown": "https://copy-css.com/snippets/follow-button.md",
  "html": "<label class=\"btn-follow\">\n  <input type=\"checkbox\" aria-label=\"Follow\">\n  <span class=\"btn-follow-off\" aria-hidden=\"true\">+ Follow</span>\n  <span class=\"btn-follow-on\" aria-hidden=\"true\">✓ Following</span>\n</label>\n<label class=\"btn-follow\">\n  <input type=\"checkbox\" aria-label=\"Follow\" checked>\n  <span class=\"btn-follow-off\" aria-hidden=\"true\">+ Follow</span>\n  <span class=\"btn-follow-on\" aria-hidden=\"true\">✓ Following</span>\n</label>",
  "css": ".btn-follow {\n  position: relative;\n  display: inline-grid;\n  min-width: 128px;\n  padding: 11px 20px;\n  border: 1.5px solid #2563eb;\n  border-radius: 999px;\n  background: #2563eb;\n  color: #fff;\n  font: 600 15px/1 system-ui, sans-serif;\n  text-align: center;\n  cursor: pointer;\n  user-select: none;\n  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;\n}\n\n.btn-follow input {\n  position: absolute;\n  inset: 0;\n  margin: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n\n/* Both labels share one grid cell, so the width never jumps */\n.btn-follow span {\n  grid-area: 1 / 1;\n}\n\n.btn-follow-on {\n  visibility: hidden;\n}\n\n.btn-follow:hover {\n  background: #1d4ed8;\n}\n\n.btn-follow:has(input:checked) {\n  border-color: #d4d4d8;\n  background: #fff;\n  color: #18181b;\n}\n\n.btn-follow:has(input:checked):hover {\n  background: #f4f4f5;\n}\n\n.btn-follow input:checked ~ .btn-follow-off {\n  visibility: hidden;\n}\n\n.btn-follow input:checked ~ .btn-follow-on {\n  visibility: visible;\n}\n\n.btn-follow:has(input:focus-visible) {\n  outline: 2px solid #2563eb;\n  outline-offset: 3px;\n}",
  "features": [
    "transitions",
    "CSS Grid",
    "the :has() selector",
    "the :checked state (no JavaScript)",
    "keyboard focus styles"
  ],
  "customProperties": []
}
