{
  "format": "putcode/playground@1",
  "id": "00000000-0000-4000-9000-000000000003",
  "url": "https://putcode.dev/u/putcode/s/fhq67ele7n",
  "title": "Pricing table with billing switch",
  "description": "Three plans with a monthly and yearly switch. Prices change with CSS alone, using :has() and attr().",
  "category": "cards",
  "tags": [
    "has",
    "attr",
    "pricing"
  ],
  "visibility": "public",
  "status": "published",
  "revision": 1,
  "author": "putcode",
  "forked_from": null,
  "created_at": "2026-12-01T21:24:56.169Z",
  "updated_at": "2026-12-01T21:24:56.169Z",
  "published_at": "2026-12-01T21:24:56.169Z",
  "source": {
    "html": "<div class=\"pricing\">\n  <fieldset class=\"billing\">\n    <legend class=\"visually-hidden\">Billing period</legend>\n    <input type=\"radio\" name=\"billing\" id=\"monthly\" checked>\n    <label for=\"monthly\">Monthly</label>\n    <input type=\"radio\" name=\"billing\" id=\"yearly\">\n    <label for=\"yearly\">Yearly <span class=\"billing__save\">Save 20%</span></label>\n  </fieldset>\n\n  <div class=\"plans\">\n    <article class=\"plan\">\n      <h2 class=\"plan__name\">Hobby</h2>\n      <p class=\"price\"><span class=\"price__amount\" data-monthly=\"0\" data-yearly=\"0\"></span><span class=\"price__period\">/ month</span></p>\n      <p class=\"plan__text\">For side projects and trying things out.</p>\n      <ul class=\"plan__list\">\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> 3 projects</li>\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> Community support</li>\n      </ul>\n      <a class=\"plan__cta\" href=\"#\">Start for free</a>\n    </article>\n    <article class=\"plan plan--featured\">\n      <p class=\"plan__badge\">Most popular</p>\n      <h2 class=\"plan__name\">Pro</h2>\n      <p class=\"price\"><span class=\"price__amount\" data-monthly=\"24\" data-yearly=\"19\"></span><span class=\"price__period\">/ month</span></p>\n      <p class=\"plan__text\">For freelancers shipping client work.</p>\n      <ul class=\"plan__list\">\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> Unlimited projects</li>\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> Custom domains</li>\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> Email support</li>\n      </ul>\n      <a class=\"plan__cta\" href=\"#\">Upgrade to Pro</a>\n    </article>\n    <article class=\"plan\">\n      <h2 class=\"plan__name\">Team</h2>\n      <p class=\"price\"><span class=\"price__amount\" data-monthly=\"48\" data-yearly=\"38\"></span><span class=\"price__period\">/ seat</span></p>\n      <p class=\"plan__text\">For teams that review and deploy together.</p>\n      <ul class=\"plan__list\">\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> Everything in Pro</li>\n        <li><svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg> Roles and SSO</li>\n      </ul>\n      <a class=\"plan__cta\" href=\"#\">Contact sales</a>\n    </article>\n  </div>\n</div>",
    "css": "body {\n  margin: 0;\n  min-height: 100vh;\n  display: grid;\n  place-items: center;\n  background: #f5f4f0;\n  color: #16171b;\n  font: 15px/1.45 system-ui, sans-serif;\n}\n\n.pricing {\n  width: min(820px, 100% - 32px);\n  padding: 24px 0;\n}\n\n.billing {\n  display: flex;\n  width: fit-content;\n  margin: 0 auto 22px;\n  padding: 4px;\n  border: 0;\n  border-radius: 999px;\n  background: #e7e5df;\n}\n\n.billing input {\n  position: absolute;\n  opacity: 0;\n}\n\n.billing label {\n  padding: 0.45em 1em;\n  border-radius: 999px;\n  color: #5f626b;\n  font-size: 0.9rem;\n  font-weight: 500;\n  cursor: pointer;\n}\n\n.billing input:checked + label {\n  background: #fff;\n  color: #16171b;\n  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);\n}\n\n.billing input:focus-visible + label {\n  outline: 2px solid #16171b;\n}\n\n.billing__save {\n  margin-left: 4px;\n  color: #2f7d4f;\n  font-size: 0.78rem;\n}\n\n.plans {\n  display: grid;\n  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));\n  gap: 12px;\n}\n\n.plan {\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  padding: 22px;\n  border: 1px solid #e2dfd8;\n  border-radius: 16px;\n  background: #fff;\n}\n\n.plan--featured {\n  border-color: #16171b;\n  box-shadow: 0 18px 40px -22px rgb(0 0 0 / 0.4);\n}\n\n.plan__badge {\n  position: absolute;\n  top: -11px;\n  left: 22px;\n  margin: 0;\n  padding: 2px 10px;\n  border-radius: 999px;\n  background: #16171b;\n  color: #fff;\n  font-size: 0.72rem;\n  font-weight: 600;\n}\n\n.plan__name {\n  margin: 0;\n  font-size: 1rem;\n}\n\n.price {\n  display: flex;\n  align-items: baseline;\n  gap: 4px;\n  margin: 10px 0 4px;\n}\n\n.price__amount::before {\n  content: \"$\" attr(data-monthly);\n  font-size: 2.2rem;\n  font-weight: 700;\n  letter-spacing: -0.03em;\n}\n\n.pricing:has(#yearly:checked) .price__amount::before {\n  content: \"$\" attr(data-yearly);\n}\n\n.price__period {\n  color: #73767f;\n  font-size: 0.85rem;\n}\n\n.plan__text {\n  margin: 0 0 14px;\n  color: #5f626b;\n  font-size: 0.88rem;\n}\n\n.plan__list {\n  display: grid;\n  gap: 8px;\n  margin: 0 0 20px;\n  padding: 0;\n  list-style: none;\n  font-size: 0.88rem;\n}\n\n.plan__list li {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n.plan__list svg {\n  flex: none;\n  color: #2f7d4f;\n}\n\n.plan__cta {\n  margin-top: auto;\n  padding: 0.65em;\n  border: 1px solid #d6d3cb;\n  border-radius: 10px;\n  color: inherit;\n  font-weight: 600;\n  text-align: center;\n  text-decoration: none;\n}\n\n.plan--featured .plan__cta {\n  border-color: #16171b;\n  background: #16171b;\n  color: #fff;\n}\n\n.visually-hidden {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}",
    "js": ""
  }
}