{
  "id": "css-tabs",
  "name": "Pure CSS Tabs",
  "category": "navigation",
  "tags": [
    "tabs",
    "radio",
    "has",
    "panels",
    "no javascript"
  ],
  "description": "Working tabs with panels and no JavaScript, powered by radio buttons and :has().",
  "url": "https://copy-css.com/snippets/css-tabs",
  "markdown": "https://copy-css.com/snippets/css-tabs.md",
  "html": "<div class=\"tabs\">\n  <div class=\"tab-list\">\n    <label><input type=\"radio\" name=\"tab\" checked>Overview</label>\n    <label><input type=\"radio\" name=\"tab\">Specs</label>\n    <label><input type=\"radio\" name=\"tab\">Reviews</label>\n  </div>\n  <div class=\"tab-panels\">\n    <div>A quick overview of the product.</div>\n    <div>Dimensions, materials and more.</div>\n    <div>4.8 out of 5 from 120 reviews.</div>\n  </div>\n</div>",
  "css": ".tabs {\n  width: 280px;\n  font: 14px/1.5 system-ui, sans-serif;\n}\n\n.tab-list {\n  display: flex;\n  gap: 4px;\n  border-bottom: 1px solid #e5e7eb;\n}\n\n.tab-list label {\n  margin-bottom: -1px;\n  padding: 10px 14px;\n  color: #6b7280;\n  font-weight: 600;\n  cursor: pointer;\n}\n\n.tab-list input {\n  position: absolute;\n  opacity: 0;\n  pointer-events: none;\n}\n\n.tab-list label:has(input:checked) {\n  color: #111;\n  box-shadow: inset 0 -2px 0 #6366f1;\n}\n\n.tab-list label:has(input:focus-visible) {\n  border-radius: 6px;\n  outline: 2px solid #6366f1;\n}\n\n.tab-panels > div {\n  display: none;\n  padding: 14px 2px;\n  color: #374151;\n}\n\n.tabs:has(label:nth-child(1) input:checked) .tab-panels > :nth-child(1),\n.tabs:has(label:nth-child(2) input:checked) .tab-panels > :nth-child(2),\n.tabs:has(label:nth-child(3) input:checked) .tab-panels > :nth-child(3) {\n  display: block;\n}",
  "features": [
    "box shadows",
    "Flexbox",
    "the :has() selector",
    "the :checked state (no JavaScript)",
    "keyboard focus styles"
  ],
  "customProperties": []
}
