{
  "id": "nps-rating-scale",
  "name": "NPS Rating Scale",
  "category": "forms",
  "tags": [
    "nps",
    "survey",
    "rating",
    "0 to 10",
    "feedback",
    "radio",
    "scale"
  ],
  "description": "A 0 to 10 \"how likely are you to recommend us\" scale where the chosen score turns red, amber or green.",
  "url": "https://copy-css.com/snippets/nps-rating-scale",
  "markdown": "https://copy-css.com/snippets/nps-rating-scale.md",
  "html": "<fieldset class=\"nps-survey\">\n  <legend>How likely are you to recommend us to a friend?</legend>\n  <div class=\"nps-survey-scale\">\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"0\">0</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"1\">1</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"2\">2</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"3\">3</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"4\">4</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"5\">5</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"6\">6</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"7\">7</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"8\">8</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"9\" checked>9</label>\n    <label><input type=\"radio\" name=\"nps-survey\" value=\"10\">10</label>\n  </div>\n  <p class=\"nps-survey-ends\"><span>Not likely</span><span>Very likely</span></p>\n</fieldset>",
  "css": ".nps-survey {\n  width: 100%;\n  min-width: 0;\n  max-width: 340px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  color: #0f172a;\n  font-family: system-ui, sans-serif;\n}\n\n.nps-survey legend {\n  margin-bottom: 10px;\n  padding: 0;\n  font-size: 14px;\n  font-weight: 600;\n}\n\n.nps-survey-scale {\n  display: grid;\n  grid-template-columns: repeat(11, minmax(0, 1fr));\n  gap: 3px;\n}\n\n.nps-survey-scale label {\n  position: relative;\n  display: grid;\n  place-items: center;\n  height: 34px;\n  border: 1px solid #e2e8f0;\n  border-radius: 6px;\n  background: #fff;\n  font-size: 13px;\n  font-weight: 600;\n  cursor: pointer;\n}\n\n.nps-survey-scale input {\n  position: absolute;\n  opacity: 0;\n  pointer-events: none;\n}\n\n.nps-survey-scale label:hover {\n  border-color: #94a3b8;\n}\n\n.nps-survey-scale label:nth-child(-n + 7):has(:checked) {\n  border-color: #ef4444;\n  background: #ef4444;\n  color: #fff;\n}\n\n.nps-survey-scale label:nth-child(n + 8):nth-child(-n + 9):has(:checked) {\n  border-color: #f59e0b;\n  background: #f59e0b;\n  color: #fff;\n}\n\n.nps-survey-scale label:nth-child(n + 10):has(:checked) {\n  border-color: #16a34a;\n  background: #16a34a;\n  color: #fff;\n}\n\n.nps-survey-scale label:has(:focus-visible) {\n  outline: 2px solid #0f172a;\n  outline-offset: 2px;\n}\n\n.nps-survey-ends {\n  display: flex;\n  justify-content: space-between;\n  margin: 6px 0 0;\n  color: #64748b;\n  font-size: 12px;\n}",
  "features": [
    "CSS Grid",
    "Flexbox",
    "the :has() selector",
    "the :checked state (no JavaScript)",
    "keyboard focus styles"
  ],
  "customProperties": []
}
