{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"star-rating-collection-with-half-stars-pure-css-radio-version-and-review-summary-in-react-and-html","type":"registry:block","title":"Star Rating Collection with Half Stars, a Pure CSS Radio Version and a Review Summary in React and HTML","description":"Free star rating components: read-only quarter stars, half-star input, a pure CSS radio version, numbered tiles and a review summary with bars. React and HTML.","dependencies":[],"files":[{"path":"components/we-inc/star-rating-collection-with-half-stars-pure-css-radio-version-and-review-summary-in-react-and-html.tsx","type":"registry:component","content":"import { Fragment, useEffect, useRef, useState, type KeyboardEvent, type ReactElement } from \"react\";\n\n/*\n  Every piece below is written once: the function renders the live demo and the\n  string next to it is that same source file, so the code you copy is the code you see.\n*/\n\ntype Lang = \"react\" | \"html\";\ntype Piece = {\n  id: string;\n  name: string;\n  blurb: string;\n  group: string;\n  Demo: () => ReactElement;\n  react: string;\n  html?: string;\n  stage: string;\n};\n\nconst s1Demo = (() => {\nconst STAR = \"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\";\n\nconst items = [\n  { name: \"Walnut serving board\", rating: 4.3, reviews: 218 },\n  { name: \"Enamel camping mug\", rating: 3.75, reviews: 64 },\n  { name: \"Wool picnic blanket\", rating: 2.5, reviews: 12 },\n];\n\n// Rounds to the nearest quarter star, then clips a row of filled stars to that width.\nfunction Stars({ value, size = \"h-5 w-5\" }: { value: number; size?: string }) {\n  const shown = Math.round(value * 4) / 4;\n  const row = (cls: string) =>\n    Array.from({ length: 5 }, (_, i) => (\n      <svg key={i} viewBox=\"0 0 24 24\" aria-hidden=\"true\" className={`${size} shrink-0 ${cls}`}>\n        <path d={STAR} />\n      </svg>\n    ));\n  return (\n    <span role=\"img\" aria-label={`Rated ${value} out of 5`} className=\"relative inline-flex\">\n      <span className=\"flex\">{row(\"fill-stone-200\")}</span>\n      <span className=\"absolute inset-y-0 left-0 flex overflow-hidden\" style={{ width: `${(shown / 5) * 100}%` }}>\n        {row(\"fill-amber-500\")}\n      </span>\n    </span>\n  );\n}\n\nfunction StarReadOnly() {\n  return (\n    <ul className=\"w-full max-w-xs divide-y divide-stone-200\">\n      {items.map((it) => (\n        <li key={it.name} className=\"py-3 first:pt-0 last:pb-0\">\n          <p className=\"text-sm font-semibold text-stone-900\">{it.name}</p>\n          <div className=\"mt-1 flex items-center gap-2\">\n            <Stars value={it.rating} />\n            <span className=\"text-sm tabular-nums text-stone-700\">{it.rating}</span>\n            <a href=\"#\" className=\"rounded text-sm text-stone-600 underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-600\">\n              {it.reviews} reviews\n            </a>\n          </div>\n        </li>\n      ))}\n    </ul>\n  );\n}\n  return StarReadOnly;\n})();\nconst s1React = \"const STAR = \\\"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\\\";\\n\\nconst items = [\\n  { name: \\\"Walnut serving board\\\", rating: 4.3, reviews: 218 },\\n  { name: \\\"Enamel camping mug\\\", rating: 3.75, reviews: 64 },\\n  { name: \\\"Wool picnic blanket\\\", rating: 2.5, reviews: 12 },\\n];\\n\\n// Rounds to the nearest quarter star, then clips a row of filled stars to that width.\\nfunction Stars({ value, size = \\\"h-5 w-5\\\" }: { value: number; size?: string }) {\\n  const shown = Math.round(value * 4) / 4;\\n  const row = (cls: string) =>\\n    Array.from({ length: 5 }, (_, i) => (\\n      <svg key={i} viewBox=\\\"0 0 24 24\\\" aria-hidden=\\\"true\\\" className={`${size} shrink-0 ${cls}`}>\\n        <path d={STAR} />\\n      </svg>\\n    ));\\n  return (\\n    <span role=\\\"img\\\" aria-label={`Rated ${value} out of 5`} className=\\\"relative inline-flex\\\">\\n      <span className=\\\"flex\\\">{row(\\\"fill-stone-200\\\")}</span>\\n      <span className=\\\"absolute inset-y-0 left-0 flex overflow-hidden\\\" style={{ width: `${(shown / 5) * 100}%` }}>\\n        {row(\\\"fill-amber-500\\\")}\\n      </span>\\n    </span>\\n  );\\n}\\n\\nexport default function StarReadOnly() {\\n  return (\\n    <ul className=\\\"w-full max-w-xs divide-y divide-stone-200\\\">\\n      {items.map((it) => (\\n        <li key={it.name} className=\\\"py-3 first:pt-0 last:pb-0\\\">\\n          <p className=\\\"text-sm font-semibold text-stone-900\\\">{it.name}</p>\\n          <div className=\\\"mt-1 flex items-center gap-2\\\">\\n            <Stars value={it.rating} />\\n            <span className=\\\"text-sm tabular-nums text-stone-700\\\">{it.rating}</span>\\n            <a href=\\\"#\\\" className=\\\"rounded text-sm text-stone-600 underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-600\\\">\\n              {it.reviews} reviews\\n            </a>\\n          </div>\\n        </li>\\n      ))}\\n    </ul>\\n  );\\n}\\n\";\n\nconst s1Html = `<!-- Set --rating on each element. Partial stars come from the gradient stop. -->\n<p class=\"stars\" style=\"--rating: 4.3\" role=\"img\" aria-label=\"Rated 4.3 out of 5\"></p>\n<p class=\"stars\" style=\"--rating: 3.75\" role=\"img\" aria-label=\"Rated 3.75 out of 5\"></p>\n\n<style>\n  .stars {\n    --size: 20px;\n    --on: #f59e0b;\n    --off: #e7e5e4;\n    margin: 4px 0;\n    width: calc(var(--size) * 5);\n    height: var(--size);\n    background: linear-gradient(90deg, var(--on) calc(var(--rating) / 5 * 100%), var(--off) 0);\n    /* One star shape, repeated five times, used as a mask. */\n    -webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z'/%3E%3C/svg%3E\") 0 0 / var(--size) var(--size) repeat-x;\n    mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z'/%3E%3C/svg%3E\") 0 0 / var(--size) var(--size) repeat-x;\n  }\n</style>\n`;\n\nconst s5Demo = (() => {\nconst STAR = \"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\";\n// Review counts per star level, 5 down to 1. The average and percentages are worked out from these.\nconst COUNTS: Record<number, number> = { 5: 146, 4: 41, 3: 17, 2: 8, 1: 6 };\n\nfunction ReviewSummaryBars() {\n  const [filter, setFilter] = useState<number | null>(null);\n  const total = Object.values(COUNTS).reduce((a, b) => a + b, 0);\n  const average = Object.entries(COUNTS).reduce((s, [k, v]) => s + Number(k) * v, 0) / total;\n  const avg = Math.round(average * 10) / 10;\n\n  return (\n    <div className=\"flex w-full max-w-sm flex-col gap-4 sm:flex-row sm:items-start\">\n      <div className=\"shrink-0\">\n        <p className=\"text-4xl font-semibold tracking-tight text-stone-900\">{avg.toFixed(1)}</p>\n        <span role=\"img\" aria-label={`Average ${avg} out of 5`} className=\"mt-1 flex\">\n          {[1, 2, 3, 4, 5].map((n) => (\n            <svg key={n} viewBox=\"0 0 24 24\" aria-hidden=\"true\" className={`h-4 w-4 ${n <= Math.round(avg) ? \"fill-amber-500\" : \"fill-stone-200\"}`}>\n              <path d={STAR} />\n            </svg>\n          ))}\n        </span>\n        <p className=\"mt-1 text-xs text-stone-600\">{total} reviews</p>\n      </div>\n      <ul className=\"flex-1 space-y-0.5\">\n        {[5, 4, 3, 2, 1].map((n) => {\n          const pct = Math.round((COUNTS[n] / total) * 100);\n          const on = filter === n;\n          return (\n            <li key={n}>\n              <button\n                type=\"button\"\n                aria-pressed={on}\n                aria-label={`${n} stars: ${COUNTS[n]} reviews, ${pct} percent. Show only these`}\n                onClick={() => setFilter(on ? null : n)}\n                className={`flex h-10 w-full items-center gap-2 rounded-md px-1.5 text-xs text-stone-700 hover:bg-stone-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-600 ${on ? \"bg-amber-50\" : \"\"}`}\n              >\n                <span className=\"w-3 tabular-nums\">{n}</span>\n                <span className=\"h-2 flex-1 overflow-hidden rounded-full bg-stone-200\">\n                  <span className=\"block h-full rounded-full bg-amber-500\" style={{ width: `${pct}%` }} />\n                </span>\n                <span className=\"w-8 text-right tabular-nums\">{pct}%</span>\n              </button>\n            </li>\n          );\n        })}\n      </ul>\n      <p role=\"status\" className=\"sr-only\">\n        {filter ? `Showing ${COUNTS[filter]} ${filter}-star reviews` : \"\"}\n      </p>\n    </div>\n  );\n}\n  return ReviewSummaryBars;\n})();\nconst s5React = \"import { useState } from \\\"react\\\";\\n\\nconst STAR = \\\"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\\\";\\n// Review counts per star level, 5 down to 1. The average and percentages are worked out from these.\\nconst COUNTS: Record<number, number> = { 5: 146, 4: 41, 3: 17, 2: 8, 1: 6 };\\n\\nexport default function ReviewSummaryBars() {\\n  const [filter, setFilter] = useState<number | null>(null);\\n  const total = Object.values(COUNTS).reduce((a, b) => a + b, 0);\\n  const average = Object.entries(COUNTS).reduce((s, [k, v]) => s + Number(k) * v, 0) / total;\\n  const avg = Math.round(average * 10) / 10;\\n\\n  return (\\n    <div className=\\\"flex w-full max-w-sm flex-col gap-4 sm:flex-row sm:items-start\\\">\\n      <div className=\\\"shrink-0\\\">\\n        <p className=\\\"text-4xl font-semibold tracking-tight text-stone-900\\\">{avg.toFixed(1)}</p>\\n        <span role=\\\"img\\\" aria-label={`Average ${avg} out of 5`} className=\\\"mt-1 flex\\\">\\n          {[1, 2, 3, 4, 5].map((n) => (\\n            <svg key={n} viewBox=\\\"0 0 24 24\\\" aria-hidden=\\\"true\\\" className={`h-4 w-4 ${n <= Math.round(avg) ? \\\"fill-amber-500\\\" : \\\"fill-stone-200\\\"}`}>\\n              <path d={STAR} />\\n            </svg>\\n          ))}\\n        </span>\\n        <p className=\\\"mt-1 text-xs text-stone-600\\\">{total} reviews</p>\\n      </div>\\n      <ul className=\\\"flex-1 space-y-0.5\\\">\\n        {[5, 4, 3, 2, 1].map((n) => {\\n          const pct = Math.round((COUNTS[n] / total) * 100);\\n          const on = filter === n;\\n          return (\\n            <li key={n}>\\n              <button\\n                type=\\\"button\\\"\\n                aria-pressed={on}\\n                aria-label={`${n} stars: ${COUNTS[n]} reviews, ${pct} percent. Show only these`}\\n                onClick={() => setFilter(on ? null : n)}\\n                className={`flex h-10 w-full items-center gap-2 rounded-md px-1.5 text-xs text-stone-700 hover:bg-stone-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-600 ${on ? \\\"bg-amber-50\\\" : \\\"\\\"}`}\\n              >\\n                <span className=\\\"w-3 tabular-nums\\\">{n}</span>\\n                <span className=\\\"h-2 flex-1 overflow-hidden rounded-full bg-stone-200\\\">\\n                  <span className=\\\"block h-full rounded-full bg-amber-500\\\" style={{ width: `${pct}%` }} />\\n                </span>\\n                <span className=\\\"w-8 text-right tabular-nums\\\">{pct}%</span>\\n              </button>\\n            </li>\\n          );\\n        })}\\n      </ul>\\n      <p role=\\\"status\\\" className=\\\"sr-only\\\">\\n        {filter ? `Showing ${COUNTS[filter]} ${filter}-star reviews` : \\\"\\\"}\\n      </p>\\n    </div>\\n  );\\n}\\n\";\n\nconst s2Demo = (() => {\nconst STAR = \"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\";\nconst WORDS = [\"Poor\", \"Fair\", \"Good\", \"Very good\", \"Excellent\"];\n\nfunction StarRadioInput() {\n  const [value, setValue] = useState(4);\n  const [hover, setHover] = useState(0);\n  const lit = hover || value;\n\n  return (\n    <fieldset className=\"w-full max-w-xs\">\n      <legend className=\"text-sm font-semibold text-stone-900\">How was your stay?</legend>\n      <div className=\"mt-2 flex\" onMouseLeave={() => setHover(0)}>\n        {WORDS.map((word, i) => {\n          const n = i + 1;\n          return (\n            <span key={n}>\n              <input\n                id={`stay-${n}`}\n                type=\"radio\"\n                name=\"stay\"\n                value={n}\n                checked={value === n}\n                onChange={() => setValue(n)}\n                className=\"peer sr-only\"\n              />\n              <label\n                htmlFor={`stay-${n}`}\n                onMouseEnter={() => setHover(n)}\n                className=\"grid h-11 w-11 cursor-pointer place-items-center rounded-lg peer-focus-visible:ring-2 peer-focus-visible:ring-amber-600\"\n              >\n                <span className=\"sr-only\">\n                  {n} {n === 1 ? \"star\" : \"stars\"}, {word}\n                </span>\n                <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" className={`h-8 w-8 transition-colors ${n <= lit ? \"fill-amber-500\" : \"fill-stone-200\"}`}>\n                  <path d={STAR} />\n                </svg>\n              </label>\n            </span>\n          );\n        })}\n      </div>\n      <p className=\"mt-1 text-sm text-stone-600\" aria-hidden=\"true\">\n        {WORDS[lit - 1]}\n      </p>\n    </fieldset>\n  );\n}\n  return StarRadioInput;\n})();\nconst s2React = \"import { useState } from \\\"react\\\";\\n\\nconst STAR = \\\"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\\\";\\nconst WORDS = [\\\"Poor\\\", \\\"Fair\\\", \\\"Good\\\", \\\"Very good\\\", \\\"Excellent\\\"];\\n\\nexport default function StarRadioInput() {\\n  const [value, setValue] = useState(4);\\n  const [hover, setHover] = useState(0);\\n  const lit = hover || value;\\n\\n  return (\\n    <fieldset className=\\\"w-full max-w-xs\\\">\\n      <legend className=\\\"text-sm font-semibold text-stone-900\\\">How was your stay?</legend>\\n      <div className=\\\"mt-2 flex\\\" onMouseLeave={() => setHover(0)}>\\n        {WORDS.map((word, i) => {\\n          const n = i + 1;\\n          return (\\n            <span key={n}>\\n              <input\\n                id={`stay-${n}`}\\n                type=\\\"radio\\\"\\n                name=\\\"stay\\\"\\n                value={n}\\n                checked={value === n}\\n                onChange={() => setValue(n)}\\n                className=\\\"peer sr-only\\\"\\n              />\\n              <label\\n                htmlFor={`stay-${n}`}\\n                onMouseEnter={() => setHover(n)}\\n                className=\\\"grid h-11 w-11 cursor-pointer place-items-center rounded-lg peer-focus-visible:ring-2 peer-focus-visible:ring-amber-600\\\"\\n              >\\n                <span className=\\\"sr-only\\\">\\n                  {n} {n === 1 ? \\\"star\\\" : \\\"stars\\\"}, {word}\\n                </span>\\n                <svg viewBox=\\\"0 0 24 24\\\" aria-hidden=\\\"true\\\" className={`h-8 w-8 transition-colors ${n <= lit ? \\\"fill-amber-500\\\" : \\\"fill-stone-200\\\"}`}>\\n                  <path d={STAR} />\\n                </svg>\\n              </label>\\n            </span>\\n          );\\n        })}\\n      </div>\\n      <p className=\\\"mt-1 text-sm text-stone-600\\\" aria-hidden=\\\"true\\\">\\n        {WORDS[lit - 1]}\\n      </p>\\n    </fieldset>\\n  );\\n}\\n\";\n\nconst s3Demo = (() => {\nconst STAR = \"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\";\n\nfunction StarHalfInput() {\n  const [value, setValue] = useState(3.5);\n  const [hover, setHover] = useState(0);\n  const lit = hover || value;\n\n  return (\n    <fieldset className=\"w-full max-w-xs\">\n      <legend className=\"text-sm font-semibold text-stone-900\">Rate this recipe</legend>\n      <div className=\"mt-2 flex items-center gap-3\">\n        <div className=\"flex\" onMouseLeave={() => setHover(0)}>\n          {[1, 2, 3, 4, 5].map((star) => {\n            const fill = Math.max(0, Math.min(1, lit - (star - 1)));\n            return (\n              <div key={star} className=\"relative h-12 w-12\">\n                <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full fill-stone-200\">\n                  <path d={STAR} />\n                </svg>\n                <div className=\"absolute inset-y-0 left-0 overflow-hidden\" style={{ width: `${fill * 100}%` }}>\n                  <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" className=\"h-12 w-12 fill-rose-500\">\n                    <path d={STAR} />\n                  </svg>\n                </div>\n                {[star - 0.5, star].map((v, half) => (\n                  <span key={v}>\n                    <input id={`recipe-${v}`} type=\"radio\" name=\"recipe\" value={v} checked={value === v} onChange={() => setValue(v)} className=\"peer sr-only\" />\n                    <label\n                      htmlFor={`recipe-${v}`}\n                      onMouseEnter={() => setHover(v)}\n                      className={`absolute inset-y-0 w-1/2 cursor-pointer rounded-md peer-focus-visible:ring-2 peer-focus-visible:ring-rose-600 ${half ? \"right-0\" : \"left-0\"}`}\n                    >\n                      <span className=\"sr-only\">{v} stars</span>\n                    </label>\n                  </span>\n                ))}\n              </div>\n            );\n          })}\n        </div>\n        <span className=\"text-sm font-semibold tabular-nums text-stone-900\" aria-hidden=\"true\">\n          {lit.toFixed(1)}\n        </span>\n      </div>\n      <p className=\"mt-1 text-xs text-stone-600\">Click the left half of a star for a half point.</p>\n    </fieldset>\n  );\n}\n  return StarHalfInput;\n})();\nconst s3React = \"import { useState } from \\\"react\\\";\\n\\nconst STAR = \\\"M12 2.6l2.8 6 6.5.7-4.9 4.4 1.4 6.4L12 16.8l-5.8 3.3 1.4-6.4-4.9-4.4 6.5-.7z\\\";\\n\\nexport default function StarHalfInput() {\\n  const [value, setValue] = useState(3.5);\\n  const [hover, setHover] = useState(0);\\n  const lit = hover || value;\\n\\n  return (\\n    <fieldset className=\\\"w-full max-w-xs\\\">\\n      <legend className=\\\"text-sm font-semibold text-stone-900\\\">Rate this recipe</legend>\\n      <div className=\\\"mt-2 flex items-center gap-3\\\">\\n        <div className=\\\"flex\\\" onMouseLeave={() => setHover(0)}>\\n          {[1, 2, 3, 4, 5].map((star) => {\\n            const fill = Math.max(0, Math.min(1, lit - (star - 1)));\\n            return (\\n              <div key={star} className=\\\"relative h-12 w-12\\\">\\n                <svg viewBox=\\\"0 0 24 24\\\" aria-hidden=\\\"true\\\" className=\\\"absolute inset-0 h-full w-full fill-stone-200\\\">\\n                  <path d={STAR} />\\n                </svg>\\n                <div className=\\\"absolute inset-y-0 left-0 overflow-hidden\\\" style={{ width: `${fill * 100}%` }}>\\n                  <svg viewBox=\\\"0 0 24 24\\\" aria-hidden=\\\"true\\\" className=\\\"h-12 w-12 fill-rose-500\\\">\\n                    <path d={STAR} />\\n                  </svg>\\n                </div>\\n                {[star - 0.5, star].map((v, half) => (\\n                  <span key={v}>\\n                    <input id={`recipe-${v}`} type=\\\"radio\\\" name=\\\"recipe\\\" value={v} checked={value === v} onChange={() => setValue(v)} className=\\\"peer sr-only\\\" />\\n                    <label\\n                      htmlFor={`recipe-${v}`}\\n                      onMouseEnter={() => setHover(v)}\\n                      className={`absolute inset-y-0 w-1/2 cursor-pointer rounded-md peer-focus-visible:ring-2 peer-focus-visible:ring-rose-600 ${half ? \\\"right-0\\\" : \\\"left-0\\\"}`}\\n                    >\\n                      <span className=\\\"sr-only\\\">{v} stars</span>\\n                    </label>\\n                  </span>\\n                ))}\\n              </div>\\n            );\\n          })}\\n        </div>\\n        <span className=\\\"text-sm font-semibold tabular-nums text-stone-900\\\" aria-hidden=\\\"true\\\">\\n          {lit.toFixed(1)}\\n        </span>\\n      </div>\\n      <p className=\\\"mt-1 text-xs text-stone-600\\\">Click the left half of a star for a half point.</p>\\n    </fieldset>\\n  );\\n}\\n\";\n\nconst s4Demo = (() => {\n// Pure CSS: no state at all. Inputs and labels must be direct siblings for ~ and :has() to work.\nconst css = `\n.css-rate { border: 0; margin: 0; padding: 0; font-family: system-ui, sans-serif; }\n.css-rate legend { font-size: 14px; font-weight: 600; color: #1c1917; }\n.css-rate-stars { display: flex; margin-top: 8px; }\n.css-rate-stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }\n.css-rate-stars label { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; cursor: pointer; }\n.css-rate-stars label::before {\n  content: \"\"; width: 30px; height: 30px; background: #d6d3d1;\n  clip-path: polygon(50% 4%, 61% 37%, 96% 37%, 68% 58%, 79% 92%, 50% 71%, 21% 92%, 32% 58%, 4% 37%, 39% 37%);\n  transition: background-color .15s;\n}\n.css-rate-stars input:checked + label::before,\n.css-rate-stars label:has(~ input:checked)::before,\n.css-rate-stars label:hover::before,\n.css-rate-stars label:has(~ label:hover)::before { background: #0d9488; }\n.css-rate-stars input:focus-visible + label { outline: 2px solid #0f766e; outline-offset: 1px; }\n.css-rate-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) { .css-rate-stars label::before { transition: none; } }\n`;\n\nfunction StarPureCss() {\n  return (\n    <fieldset className=\"css-rate\">\n      <style>{css}</style>\n      <legend>Rate the delivery</legend>\n      <div className=\"css-rate-stars\">\n        {[1, 2, 3, 4, 5].map((n) => (\n          <Fragment key={n}>\n            <input type=\"radio\" id={`deliv-${n}`} name=\"delivery\" value={n} defaultChecked={n === 3} />\n            <label htmlFor={`deliv-${n}`}>\n              <span className=\"css-rate-sr\">{n} {n === 1 ? \"star\" : \"stars\"}</span>\n            </label>\n          </Fragment>\n        ))}\n      </div>\n    </fieldset>\n  );\n}\n  return StarPureCss;\n})();\nconst s4React = \"import { Fragment } from \\\"react\\\";\\n\\n// Pure CSS: no state at all. Inputs and labels must be direct siblings for ~ and :has() to work.\\nconst css = `\\n.css-rate { border: 0; margin: 0; padding: 0; font-family: system-ui, sans-serif; }\\n.css-rate legend { font-size: 14px; font-weight: 600; color: #1c1917; }\\n.css-rate-stars { display: flex; margin-top: 8px; }\\n.css-rate-stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }\\n.css-rate-stars label { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; cursor: pointer; }\\n.css-rate-stars label::before {\\n  content: \\\"\\\"; width: 30px; height: 30px; background: #d6d3d1;\\n  clip-path: polygon(50% 4%, 61% 37%, 96% 37%, 68% 58%, 79% 92%, 50% 71%, 21% 92%, 32% 58%, 4% 37%, 39% 37%);\\n  transition: background-color .15s;\\n}\\n.css-rate-stars input:checked + label::before,\\n.css-rate-stars label:has(~ input:checked)::before,\\n.css-rate-stars label:hover::before,\\n.css-rate-stars label:has(~ label:hover)::before { background: #0d9488; }\\n.css-rate-stars input:focus-visible + label { outline: 2px solid #0f766e; outline-offset: 1px; }\\n.css-rate-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\\n@media (prefers-reduced-motion: reduce) { .css-rate-stars label::before { transition: none; } }\\n`;\\n\\nexport default function StarPureCss() {\\n  return (\\n    <fieldset className=\\\"css-rate\\\">\\n      <style>{css}</style>\\n      <legend>Rate the delivery</legend>\\n      <div className=\\\"css-rate-stars\\\">\\n        {[1, 2, 3, 4, 5].map((n) => (\\n          <Fragment key={n}>\\n            <input type=\\\"radio\\\" id={`deliv-${n}`} name=\\\"delivery\\\" value={n} defaultChecked={n === 3} />\\n            <label htmlFor={`deliv-${n}`}>\\n              <span className=\\\"css-rate-sr\\\">{n} {n === 1 ? \\\"star\\\" : \\\"stars\\\"}</span>\\n            </label>\\n          </Fragment>\\n        ))}\\n      </div>\\n    </fieldset>\\n  );\\n}\\n\";\n\nconst s4Html = `<fieldset class=\"css-rate\">\n  <legend>Rate the delivery</legend>\n  <div class=\"css-rate-stars\">\n    <input type=\"radio\" id=\"deliv-1\" name=\"delivery\" value=\"1\"><label for=\"deliv-1\"><span class=\"css-rate-sr\">1 star</span></label>\n    <input type=\"radio\" id=\"deliv-2\" name=\"delivery\" value=\"2\"><label for=\"deliv-2\"><span class=\"css-rate-sr\">2 stars</span></label>\n    <input type=\"radio\" id=\"deliv-3\" name=\"delivery\" value=\"3\" checked><label for=\"deliv-3\"><span class=\"css-rate-sr\">3 stars</span></label>\n    <input type=\"radio\" id=\"deliv-4\" name=\"delivery\" value=\"4\"><label for=\"deliv-4\"><span class=\"css-rate-sr\">4 stars</span></label>\n    <input type=\"radio\" id=\"deliv-5\" name=\"delivery\" value=\"5\"><label for=\"deliv-5\"><span class=\"css-rate-sr\">5 stars</span></label>\n  </div>\n</fieldset>\n\n<style>\n.css-rate { border: 0; margin: 0; padding: 0; font-family: system-ui, sans-serif; }\n.css-rate legend { font-size: 14px; font-weight: 600; color: #1c1917; }\n.css-rate-stars { display: flex; margin-top: 8px; }\n.css-rate-stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }\n.css-rate-stars label { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; cursor: pointer; }\n.css-rate-stars label::before {\n  content: \"\"; width: 30px; height: 30px; background: #d6d3d1;\n  clip-path: polygon(50% 4%, 61% 37%, 96% 37%, 68% 58%, 79% 92%, 50% 71%, 21% 92%, 32% 58%, 4% 37%, 39% 37%);\n  transition: background-color .15s;\n}\n.css-rate-stars input:checked + label::before,\n.css-rate-stars label:has(~ input:checked)::before,\n.css-rate-stars label:hover::before,\n.css-rate-stars label:has(~ label:hover)::before { background: #0d9488; }\n.css-rate-stars input:focus-visible + label { outline: 2px solid #0f766e; outline-offset: 1px; }\n.css-rate-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) { .css-rate-stars label::before { transition: none; } }\n</style>\n`;\n\nconst s6Demo = (() => {\nconst LABELS = [\"Not useful\", \"Slightly useful\", \"Useful\", \"Very useful\", \"Essential\"];\n\n// Custom radio group with roving tabindex, following the WAI-ARIA radio group pattern.\nfunction StarRovingTiles() {\n  const [value, setValue] = useState(4);\n  const refs = useRef<(HTMLButtonElement | null)[]>([]);\n  const focusable = value ? value - 1 : 0;\n\n  function choose(i: number) {\n    setValue(i + 1);\n    refs.current[i]?.focus();\n  }\n\n  function onKeyDown(i: number, e: KeyboardEvent<HTMLButtonElement>) {\n    const last = LABELS.length - 1;\n    const next =\n      e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? (i === last ? 0 : i + 1)\n      : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? (i === 0 ? last : i - 1)\n      : null;\n    if (next === null) return;\n    e.preventDefault();\n    choose(next);\n  }\n\n  return (\n    <div className=\"w-full max-w-xs rounded-xl bg-stone-900 p-4 text-stone-100\">\n      <p id=\"guide-q\" className=\"text-sm font-semibold\">\n        Was this guide useful?\n      </p>\n      <div role=\"radiogroup\" aria-labelledby=\"guide-q\" className=\"mt-3 grid grid-cols-5 gap-1.5\">\n        {LABELS.map((label, i) => {\n          const checked = value === i + 1;\n          const lit = i < value;\n          return (\n            <button\n              key={label}\n              ref={(el) => {\n                refs.current[i] = el;\n              }}\n              type=\"button\"\n              role=\"radio\"\n              aria-checked={checked}\n              aria-label={`${i + 1} of 5, ${label}`}\n              tabIndex={i === focusable ? 0 : -1}\n              onClick={() => choose(i)}\n              onKeyDown={(e) => onKeyDown(i, e)}\n              className={`flex h-12 flex-col items-center justify-center rounded-lg text-xs font-semibold tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300 ${\n                lit ? \"bg-amber-400 text-stone-950\" : \"bg-stone-800 text-stone-300 hover:bg-stone-700\"\n              }`}\n            >\n              {i + 1}\n            </button>\n          );\n        })}\n      </div>\n      <div className=\"mt-3 flex min-h-[40px] items-center justify-between\">\n        <p className=\"text-sm text-stone-300\">{value ? LABELS[value - 1] : \"Pick a score from 1 to 5\"}</p>\n        {value > 0 && (\n          <button type=\"button\" onClick={() => setValue(0)} className=\"h-10 rounded-md px-3 text-sm text-stone-200 hover:bg-stone-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300\">\n            Clear\n          </button>\n        )}\n      </div>\n    </div>\n  );\n}\n  return StarRovingTiles;\n})();\nconst s6React = \"import { useRef, useState, type KeyboardEvent } from \\\"react\\\";\\n\\nconst LABELS = [\\\"Not useful\\\", \\\"Slightly useful\\\", \\\"Useful\\\", \\\"Very useful\\\", \\\"Essential\\\"];\\n\\n// Custom radio group with roving tabindex, following the WAI-ARIA radio group pattern.\\nexport default function StarRovingTiles() {\\n  const [value, setValue] = useState(4);\\n  const refs = useRef<(HTMLButtonElement | null)[]>([]);\\n  const focusable = value ? value - 1 : 0;\\n\\n  function choose(i: number) {\\n    setValue(i + 1);\\n    refs.current[i]?.focus();\\n  }\\n\\n  function onKeyDown(i: number, e: KeyboardEvent<HTMLButtonElement>) {\\n    const last = LABELS.length - 1;\\n    const next =\\n      e.key === \\\"ArrowRight\\\" || e.key === \\\"ArrowDown\\\" ? (i === last ? 0 : i + 1)\\n      : e.key === \\\"ArrowLeft\\\" || e.key === \\\"ArrowUp\\\" ? (i === 0 ? last : i - 1)\\n      : null;\\n    if (next === null) return;\\n    e.preventDefault();\\n    choose(next);\\n  }\\n\\n  return (\\n    <div className=\\\"w-full max-w-xs rounded-xl bg-stone-900 p-4 text-stone-100\\\">\\n      <p id=\\\"guide-q\\\" className=\\\"text-sm font-semibold\\\">\\n        Was this guide useful?\\n      </p>\\n      <div role=\\\"radiogroup\\\" aria-labelledby=\\\"guide-q\\\" className=\\\"mt-3 grid grid-cols-5 gap-1.5\\\">\\n        {LABELS.map((label, i) => {\\n          const checked = value === i + 1;\\n          const lit = i < value;\\n          return (\\n            <button\\n              key={label}\\n              ref={(el) => {\\n                refs.current[i] = el;\\n              }}\\n              type=\\\"button\\\"\\n              role=\\\"radio\\\"\\n              aria-checked={checked}\\n              aria-label={`${i + 1} of 5, ${label}`}\\n              tabIndex={i === focusable ? 0 : -1}\\n              onClick={() => choose(i)}\\n              onKeyDown={(e) => onKeyDown(i, e)}\\n              className={`flex h-12 flex-col items-center justify-center rounded-lg text-xs font-semibold tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300 ${\\n                lit ? \\\"bg-amber-400 text-stone-950\\\" : \\\"bg-stone-800 text-stone-300 hover:bg-stone-700\\\"\\n              }`}\\n            >\\n              {i + 1}\\n            </button>\\n          );\\n        })}\\n      </div>\\n      <div className=\\\"mt-3 flex min-h-[40px] items-center justify-between\\\">\\n        <p className=\\\"text-sm text-stone-300\\\">{value ? LABELS[value - 1] : \\\"Pick a score from 1 to 5\\\"}</p>\\n        {value > 0 && (\\n          <button type=\\\"button\\\" onClick={() => setValue(0)} className=\\\"h-10 rounded-md px-3 text-sm text-stone-200 hover:bg-stone-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300\\\">\\n            Clear\\n          </button>\\n        )}\\n      </div>\\n    </div>\\n  );\\n}\\n\";\n\nconst PIECES: Piece[] = [\n  { id: \"s1\", name: \"Read-only score, quarter-star fill\", blurb: \"A clipped row of filled stars over an empty row, labelled once as an image.\", group: \"display\", Demo: s1Demo, react: s1React, html: s1Html, stage: \"bg-[#faf8f4] ring-1 ring-inset ring-stone-200/80\" },\n  { id: \"s5\", name: \"Review summary with bars\", blurb: \"Average worked out from the counts, with bars that filter by star level.\", group: \"display\", Demo: s5Demo, react: s5React, stage: \"bg-[#faf8f4] ring-1 ring-inset ring-stone-200/80\" },\n  { id: \"s2\", name: \"Star input on native radios\", blurb: \"Hover preview, a word for each level and real radio keyboard behaviour.\", group: \"input\", Demo: s2Demo, react: s2React, stage: \"bg-[#faf8f4] ring-1 ring-inset ring-stone-200/80\" },\n  { id: \"s3\", name: \"Half-star input\", blurb: \"Two hit areas per star give scores from 0.5 to 5.\", group: \"input\", Demo: s3Demo, react: s3React, stage: \"bg-[#faf8f4] ring-1 ring-inset ring-stone-200/80\" },\n  { id: \"s4\", name: \"Pure CSS radio rating\", blurb: \"No state or script. Radios in their natural order coloured with :has().\", group: \"input\", Demo: s4Demo, react: s4React, html: s4Html, stage: \"bg-[#faf8f4] ring-1 ring-inset ring-stone-200/80\" },\n  { id: \"s6\", name: \"Numbered score tiles\", blurb: \"A custom radio group with roving focus and a clear button.\", group: \"input\", Demo: s6Demo, react: s6React, stage: \"bg-[#faf8f4] ring-1 ring-inset ring-stone-200/80\" }\n];\nconst GROUPS: { key: string; label: string }[] = [{\"key\":\"display\",\"label\":\"Display only\"},{\"key\":\"input\",\"label\":\"Rating inputs\"}];\nconst TEXT: { eyebrow: string; title: string; lead: string; refTitle: string; refNote: string } = {\"eyebrow\":\"React · pure CSS · HTML\",\"title\":\"Star ratings you can read and set\",\"lead\":\"Six rating pieces: a read-only score with quarter-star fill, a review summary with filter bars, a radio-based star input, a half-star input, a version with no script at all and a numbered score picker.\",\"refTitle\":\"Which markup to use\",\"refNote\":\"Roles and keys follow the radio group pattern in the WAI-ARIA Authoring Practices Guide. Support for :has() and CSS masks is per MDN's compatibility data.\"};\nconst REF_HEAD: string[] = [\"Case\",\"Markup\",\"Keyboard\"];\nconst REF_ROWS: string[][] = [\n  [\n    \"Showing a score\",\n    \"One element with role=\\\"img\\\" and aria-label=\\\"Rated 4.3 out of 5\\\". The drawn stars are aria-hidden.\",\n    \"Not focusable; nothing to operate.\"\n  ],\n  [\n    \"Choosing a score\",\n    \"Native radio inputs in a fieldset with a legend; each label holds a star and hidden text.\",\n    \"Tab enters the group, arrow keys move and select, as with any radio set.\"\n  ],\n  [\n    \"Half stars\",\n    \"Ten radios, two per star, each label covering one half.\",\n    \"Arrow keys step by half a point.\"\n  ],\n  [\n    \"No JavaScript\",\n    \"Radios plus :has() to colour the stars before the checked one. Needs a browser with :has() support.\",\n    \"Native radio keys.\"\n  ],\n  [\n    \"Custom buttons\",\n    \"role=\\\"radiogroup\\\" with role=\\\"radio\\\" buttons, aria-checked and a roving tabindex.\",\n    \"Arrows move, check and wrap; only one button is in the tab order.\"\n  ],\n  [\n    \"Summary bars\",\n    \"Buttons with aria-pressed to filter reviews by star level.\",\n    \"Tab and Enter or Space.\"\n  ]\n];\n\nconst COPY_ICON = \"M9 9h10v10H9zM5 15V5h10\";\nconst CHECK_ICON = \"M5 12.5l4.5 4.5L19 7.5\";\nconst CODE_ICON = \"M8 7l-5 5 5 5M16 7l5 5-5 5\";\n\nexport default function StarRatingCollection() {\n  const [group, setGroup] = useState(\"all\");\n  const [langs, setLangs] = useState<Record<string, Lang>>({});\n  const [open, setOpen] = useState<string | null>(null);\n  const [copied, setCopied] = useState<string | null>(null);\n  const [announce, setAnnounce] = useState(\"\");\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    []\n  );\n\n  const shown = group === \"all\" ? PIECES : PIECES.filter((p) => p.group === group);\n  const langOf = (p: Piece): Lang => (p.html ? langs[p.id] ?? \"react\" : \"react\");\n  const codeOf = (p: Piece) => (langOf(p) === \"html\" && p.html ? p.html : p.react);\n  const langName = (l: Lang) => (l === \"html\" ? \"HTML, CSS and JS\" : \"React and Tailwind\");\n\n  async function copy(p: Piece) {\n    let ok = false;\n    try {\n      await navigator.clipboard.writeText(codeOf(p));\n      ok = true;\n    } catch {\n      ok = false;\n    }\n    if (!ok) setOpen(p.id);\n    setCopied(ok ? p.id : null);\n    setAnnounce(ok ? `${p.name}: ${langName(langOf(p))} copied` : \"Copy was blocked, so the code is shown under the demo for you to select\");\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setCopied(null), 1600);\n  }\n\n  const ring = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-600 focus-visible:ring-offset-2\";\n  const chip = `inline-flex min-h-[40px] items-center gap-1.5 whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors ${ring}`;\n\n  return (\n    <section\n      className=\"bg-white px-4 py-12 sm:px-8 sm:py-14\"\n      style={{ fontFamily: 'Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif' }}\n    >\n      <div className=\"mx-auto max-w-6xl\">\n        <header className=\"max-w-3xl\">\n          <p className=\"font-mono text-[12px] uppercase tracking-[0.18em] text-stone-600\">{TEXT.eyebrow}</p>\n          <h2 className=\"mt-3 text-[32px] font-semibold leading-[1.08] tracking-[-0.03em] text-stone-950 sm:text-[42px]\">{TEXT.title}</h2>\n          <p className=\"mt-4 max-w-2xl text-[15px] leading-relaxed text-stone-600\">{TEXT.lead}</p>\n        </header>\n\n        <div role=\"group\" aria-label=\"Filter the collection\" className=\"mt-8 flex flex-wrap gap-1.5 border-y border-stone-300/70 py-4\">\n          {[{ key: \"all\", label: \"All\" }, ...GROUPS, { key: \"ref\", label: \"Reference table\" }].map((g) => {\n            const on = group === g.key;\n            const n = g.key === \"ref\" ? REF_ROWS.length : g.key === \"all\" ? PIECES.length : PIECES.filter((p) => p.group === g.key).length;\n            return (\n              <button\n                key={g.key}\n                type=\"button\"\n                aria-pressed={on}\n                onClick={() => setGroup(g.key)}\n                className={`${chip} ${on ? \"bg-stone-900 text-white\" : \"bg-white text-stone-700 ring-1 ring-inset ring-stone-300 hover:bg-stone-100\"}`}\n              >\n                {g.label}\n                <span className={`font-mono text-[11px] ${on ? \"opacity-75\" : \"text-stone-500\"}`}>{n}</span>\n              </button>\n            );\n          })}\n        </div>\n\n        <p className=\"sr-only\" aria-live=\"polite\">\n          {announce}\n        </p>\n\n        {group !== \"ref\" && (\n        <ul className=\"mt-6 grid grid-cols-1 items-start gap-4 md:grid-cols-2 lg:grid-cols-3\">\n          {shown.map((p) => {\n            const isOpen = open === p.id;\n            const l = langOf(p);\n            return (\n              <li\n                key={p.id}\n                className={`flex min-w-0 flex-col rounded-2xl border border-stone-200 bg-white shadow-[0_1px_2px_rgba(28,25,23,0.05)] ${isOpen ? \"md:col-span-2 lg:col-span-3\" : \"\"}`}\n              >\n                <div className=\"px-4 pt-4\">\n                  <h3 className=\"text-[14px] font-semibold text-stone-950\">{p.name}</h3>\n                  <p className=\"mt-0.5 text-[13px] leading-snug text-stone-600\">{p.blurb}</p>\n                </div>\n                <div className={`relative mx-3 mt-3 flex min-w-0 items-start justify-center rounded-xl px-3 py-6 sm:px-5 ${p.stage}`}>\n                  <p.Demo />\n                </div>\n                <div className=\"flex flex-wrap items-center gap-2 px-3 py-3\">\n                  {p.html && (\n                    <div role=\"group\" aria-label={`Code version for ${p.name}`} className=\"inline-flex rounded-lg bg-stone-100 p-0.5\">\n                      {([\"react\", \"html\"] as Lang[]).map((x) => (\n                        <button\n                          key={x}\n                          type=\"button\"\n                          aria-pressed={l === x}\n                          onClick={() => setLangs({ ...langs, [p.id]: x })}\n                          className={`h-9 rounded-md px-2.5 text-[12px] font-semibold ${ring} ${l === x ? \"bg-white text-stone-950 shadow-sm\" : \"text-stone-600 hover:text-stone-900\"}`}\n                        >\n                          {x === \"react\" ? \"React\" : \"HTML\"}\n                        </button>\n                      ))}\n                    </div>\n                  )}\n                  <span className=\"flex-1\" />\n                  <button\n                    type=\"button\"\n                    aria-expanded={isOpen}\n                    aria-controls={`code-${p.id}`}\n                    onClick={() => setOpen(isOpen ? null : p.id)}\n                    className={`inline-flex h-10 items-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold text-stone-700 hover:bg-stone-100 ${ring}`}\n                  >\n                    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-4 w-4\">\n                      <path d={CODE_ICON} />\n                    </svg>\n                    {isOpen ? \"Hide code\" : \"Code\"}\n                  </button>\n                  <button\n                    type=\"button\"\n                    onClick={() => copy(p)}\n                    aria-label={`Copy ${langName(l)} for ${p.name}`}\n                    className={`inline-flex h-10 items-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold transition-colors ${ring} ${copied === p.id ? \"bg-emerald-700 text-white\" : \"bg-stone-900 text-white hover:bg-stone-700\"}`}\n                  >\n                    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-3.5 w-3.5\">\n                      <path d={copied === p.id ? CHECK_ICON : COPY_ICON} />\n                    </svg>\n                    {copied === p.id ? \"Copied\" : \"Copy\"}\n                  </button>\n                </div>\n                {isOpen && (\n                  <pre\n                    id={`code-${p.id}`}\n                    tabIndex={0}\n                    aria-label={`${langName(l)} for ${p.name}`}\n                    className=\"max-h-[440px] overflow-auto rounded-b-2xl border-t border-stone-800 bg-[#121316] p-4 font-mono text-[12px] leading-[1.65] text-stone-200\"\n                  >\n                    <code>{codeOf(p)}</code>\n                  </pre>\n                )}\n              </li>\n            );\n          })}\n        </ul>\n        )}\n\n        {group === \"ref\" && (\n        <div className=\"mt-6\">\n          <h3 className=\"text-[17px] font-semibold tracking-tight text-stone-950\">{TEXT.refTitle}</h3>\n          <p className=\"mt-1 max-w-3xl text-[13px] leading-relaxed text-stone-600\">{TEXT.refNote}</p>\n          <div className=\"mt-4 overflow-x-auto rounded-xl border border-stone-200 bg-white\" tabIndex={0} role=\"region\" aria-label={TEXT.refTitle}>\n            <table className=\"w-full min-w-[600px] text-left text-[13px]\">\n              <thead className=\"bg-stone-50 text-stone-700\">\n                <tr>\n                  {REF_HEAD.map((h) => (\n                    <th key={h} scope=\"col\" className=\"px-4 py-2.5 font-semibold\">\n                      {h}\n                    </th>\n                  ))}\n                </tr>\n              </thead>\n              <tbody>\n                {REF_ROWS.map((r, i) => (\n                  <tr key={i} className=\"border-t border-stone-200 align-top\">\n                    {r.map((c, j) =>\n                      j === 0 ? (\n                        <th key={j} scope=\"row\" className=\"whitespace-nowrap px-4 py-2.5 font-mono text-[12px] font-medium text-stone-900\">\n                          {c}\n                        </th>\n                      ) : (\n                        <td key={j} className=\"px-4 py-2.5 leading-relaxed text-stone-700\">\n                          {c}\n                        </td>\n                      )\n                    )}\n                  </tr>\n                ))}\n              </tbody>\n            </table>\n          </div>\n        </div>\n        )}\n      </div>\n    </section>\n  );\n}\n"}]}
