{
  "id": "input-with-icon",
  "name": "Input with Icon",
  "category": "forms",
  "tags": [
    "icon",
    "email",
    "leading icon",
    "valid",
    "checkmark",
    "input"
  ],
  "description": "An email field with a leading mail icon that tints on focus and a green check that appears once the value is valid.",
  "url": "https://copy-css.com/snippets/input-with-icon",
  "markdown": "https://copy-css.com/snippets/input-with-icon.md",
  "html": "<label class=\"icon-field\">\n  <span class=\"icon-field-label\">Work email</span>\n  <span class=\"icon-field-box\">\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\"/><path d=\"m3 7 9 6 9-6\"/></svg>\n    <input type=\"email\" name=\"email\" autocomplete=\"email\" placeholder=\"you@company.com\" value=\"sam@studio.dev\">\n  </span>\n</label>",
  "css": ".icon-field {\n  display: grid;\n  gap: 6px;\n  width: 260px;\n  font-family: system-ui, sans-serif;\n}\n\n.icon-field-label {\n  color: #3b0764;\n  font-size: 13px;\n  font-weight: 600;\n}\n\n.icon-field-box {\n  position: relative;\n  display: block;\n}\n\n.icon-field svg {\n  position: absolute;\n  top: 50%;\n  left: 12px;\n  width: 18px;\n  height: 18px;\n  fill: none;\n  stroke: #a1a1aa;\n  stroke-width: 2;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n  transform: translateY(-50%);\n  pointer-events: none;\n  transition: stroke 0.2s ease;\n}\n\n.icon-field input {\n  box-sizing: border-box;\n  width: 100%;\n  padding: 11px 38px 11px 40px;\n  border: 1.5px solid #ddd6fe;\n  border-radius: 10px;\n  background: #fff no-repeat right 12px center / 16px;\n  color: #18181b;\n  font: 15px system-ui, sans-serif;\n  outline: none;\n}\n\n.icon-field input:focus {\n  border-color: #7c3aed;\n  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);\n}\n\n.icon-field-box:focus-within svg {\n  stroke: #7c3aed;\n}\n\n.icon-field input:valid:not(:placeholder-shown) {\n  background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17 19 7'/%3E%3C/svg%3E\");\n}",
  "features": [
    "transitions",
    "transforms",
    "box shadows",
    "CSS Grid"
  ],
  "customProperties": []
}
