{
  "id": "input-states",
  "name": "Input States",
  "category": "forms",
  "tags": [
    "error",
    "helper text",
    "disabled",
    "aria-invalid",
    "design system",
    "validation"
  ],
  "description": "Default, error and disabled text field states with helper and error text linked via aria-describedby.",
  "url": "https://copy-css.com/snippets/input-states",
  "markdown": "https://copy-css.com/snippets/input-states.md",
  "html": "<div class=\"field-states\">\n  <label>\n    Username\n    <input type=\"text\" value=\"mira\" aria-describedby=\"field-states-hint\">\n    <small id=\"field-states-hint\">Letters and numbers only.</small>\n  </label>\n  <label>\n    Email\n    <input type=\"email\" value=\"mira@\" aria-invalid=\"true\" aria-describedby=\"field-states-error\">\n    <small id=\"field-states-error\">Enter a full email address.</small>\n  </label>\n  <label>\n    Plan\n    <input type=\"text\" value=\"Free\" disabled>\n  </label>\n</div>",
  "css": ".field-states {\n  display: grid;\n  gap: 12px;\n  width: 240px;\n  font-family: system-ui, sans-serif;\n}\n\n.field-states label {\n  display: grid;\n  gap: 4px;\n  color: #27272a;\n  font-size: 13px;\n  font-weight: 600;\n}\n\n.field-states input {\n  padding: 8px 11px;\n  border: 1.5px solid #d4d4d8;\n  border-radius: 8px;\n  background: #fff;\n  color: #18181b;\n  font: 14px system-ui, sans-serif;\n}\n\n.field-states input:focus-visible {\n  border-color: #2563eb;\n  outline: 3px solid rgba(37, 99, 235, 0.2);\n  outline-offset: 0;\n}\n\n.field-states small {\n  color: #71717a;\n  font-size: 12px;\n  font-weight: 400;\n}\n\n.field-states input[aria-invalid=\"true\"] {\n  border-color: #dc2626;\n}\n\n.field-states input[aria-invalid=\"true\"]:focus-visible {\n  outline-color: rgba(220, 38, 38, 0.2);\n}\n\n.field-states input[aria-invalid=\"true\"] + small {\n  color: #dc2626;\n}\n\n.field-states input[aria-invalid=\"true\"] + small::before {\n  content: \"⚠ \";\n}\n\n.field-states input:disabled {\n  border-color: #e4e4e7;\n  background: #f4f4f5;\n  color: #a1a1aa;\n  cursor: not-allowed;\n}",
  "features": [
    "CSS Grid",
    "keyboard focus styles"
  ],
  "customProperties": []
}
