{
  "id": "color-swatches",
  "name": "Color Swatch Picker",
  "category": "forms",
  "tags": [
    "swatch",
    "color",
    "variant",
    "radio",
    "product",
    "shop"
  ],
  "description": "Round color swatches for product variants, built on radio buttons with a ring around the chosen one.",
  "url": "https://copy-css.com/snippets/color-swatches",
  "markdown": "https://copy-css.com/snippets/color-swatches.md",
  "html": "<fieldset class=\"swatches\">\n  <legend>Color</legend>\n  <label style=\"--c: #18181b\"><input type=\"radio\" name=\"color\" aria-label=\"Black\" checked></label>\n  <label style=\"--c: #d6c3a5\"><input type=\"radio\" name=\"color\" aria-label=\"Sand\"></label>\n  <label style=\"--c: #84a98c\"><input type=\"radio\" name=\"color\" aria-label=\"Sage\"></label>\n  <label style=\"--c: #1e3a8a\"><input type=\"radio\" name=\"color\" aria-label=\"Navy\"></label>\n  <label style=\"--c: #e11d48\"><input type=\"radio\" name=\"color\" aria-label=\"Rose\"></label>\n</fieldset>",
  "css": ".swatches {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 12px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n}\n\n.swatches legend {\n  width: 100%;\n  margin-bottom: 12px;\n  padding: 0;\n  color: #3f3f46;\n  font: 700 14px system-ui, sans-serif;\n}\n\n/* Each label sets its own --c */\n.swatches label {\n  position: relative;\n  width: 32px;\n  height: 32px;\n  border-radius: 50%;\n  background: var(--c);\n  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);\n  cursor: pointer;\n  transition: box-shadow 0.2s ease;\n}\n\n.swatches input {\n  position: absolute;\n  inset: 0;\n  margin: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n\n.swatches label:has(:checked) {\n  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c);\n}\n\n.swatches label:has(:focus-visible) {\n  outline: 2px solid #6366f1;\n  outline-offset: 7px;\n}",
  "features": [
    "transitions",
    "box shadows",
    "Flexbox",
    "the :has() selector",
    "the :checked state (no JavaScript)",
    "keyboard focus styles",
    "custom properties"
  ],
  "customProperties": []
}
