{
 "id": "code-input",
 "name": "Code input",
 "purpose": "Six boxes for a verification code that move to the next box as you type and fill all at once when you paste, with a resend countdown and a wrong-code error.",
 "use_when": [
  "for a one-time sign-in or verification code",
  "a second sign-in step after a password, or confirming a new email or phone number"
 ],
 "avoid_when": [
  "the first sign-in screen with email and password: use sign-in-form",
  "a code longer or shorter than six digits: the six boxes are fixed in the markup, so a single text field fits better",
  "a confirmation with no code to type: use confirm-dialog"
 ],
 "type": "form",
 "style": "quiet",
 "width": "narrow",
 "tags": {
  "audience": "work",
  "industries": [
   "saas",
   "security",
   "finance",
   "any"
  ],
  "keywords": [
   "verification code",
   "otp",
   "two-step",
   "pin",
   "sign in"
  ]
 },
 "root": ".odl-code-input",
 "parts": [
  {
   "name": "icon",
   "selector": ".odl-mark",
   "what": "an icon for where the code was sent",
   "slot": "media"
  },
  {
   "name": "title",
   "selector": ".odl-code-input h2",
   "what": "the heading, such as 'Check your email'",
   "slot": "text"
  },
  {
   "name": "intro",
   "selector": ".odl-head p",
   "what": "where the code went and how long it works, with the masked address in bold",
   "slot": "rich"
  },
  {
   "name": "label",
   "selector": "legend",
   "what": "the name of the code field",
   "slot": "text"
  },
  {
   "name": "boxes",
   "selector": ".odl-boxes input",
   "what": "one box per digit, three, a dash, then three",
   "slot": "input"
  },
  {
   "name": "message",
   "selector": ".odl-msg",
   "what": "help text, or the error when the code is wrong",
   "slot": "text"
  },
  {
   "name": "verify",
   "selector": ".odl-verify",
   "what": "the main action",
   "slot": "action"
  },
  {
   "name": "resend",
   "selector": ".odl-resend",
   "what": "resend link with a countdown before it can be used",
   "slot": "action"
  },
  {
   "name": "change",
   "selector": ".odl-foot .odl-link:last-child",
   "what": "go back and use another address",
   "slot": "action"
  }
 ],
 "data": {
  "type": "object",
  "required": [
   "title",
   "destination"
  ],
  "properties": {
   "title": {
    "type": "string",
    "maxLength": 32,
    "part": "title"
   },
   "destination": {
    "type": "string",
    "maxLength": 28,
    "part": "intro"
   },
   "intro": {
    "type": "string",
    "maxLength": 120,
    "part": "intro"
   },
   "label": {
    "type": "string",
    "maxLength": 28,
    "part": "label"
   },
   "length": {
    "const": 6,
    "part": "boxes"
   },
   "help": {
    "type": "string",
    "maxLength": 80,
    "part": "message"
   },
   "error": {
    "type": "string",
    "maxLength": 90,
    "part": "message"
   },
   "resend_seconds": {
    "type": "integer",
    "minimum": 0,
    "maximum": 600,
    "part": "resend"
   },
   "actions": {
    "type": "object",
    "properties": {
     "verify": {
      "type": "string",
      "maxLength": 20,
      "part": "verify"
     },
     "change": {
      "type": "string",
      "maxLength": 28,
      "part": "change"
     }
    }
   }
  }
 },
 "states": {
  "shown": [
   "hover",
   "focus",
   "filled",
   "error",
   "resend waiting",
   "resend ready",
   "disabled verify"
  ],
  "edge": {
   "empty": {
    "status": "handled",
    "how": "when any box is empty the Verify button is disabled; after a resend the boxes clear and the message explains what to do",
    "evidence": "verify.disabled = boxes.some((b) => !b.value)"
   },
   "loading": {
    "status": "handled",
    "evidence": "data-od-slot",
    "how": "the Smart UI renderer draws each marked slot as a quiet block of its size while the data arrives; the static file shows the filled part"
   },
   "error": {
    "status": "shown",
    "how": "a wrong code turns every box red and shows the message with an alert icon; typing clears it",
    "evidence": ":has(.odl-error:not(:empty)"
   },
   "disabled": {
    "status": "shown",
    "how": "Resend is disabled during the countdown; Verify is disabled until all six boxes have a digit",
    "evidence": ".odl-link:disabled"
   },
   "overflow": {
    "status": "handled",
    "how": "the six boxes shrink with the card, and the card's padding gets smaller on a phone",
    "evidence": "repeat(3, minmax(0, 1fr)) auto repeat(3, minmax(0, 1fr))"
   },
   "long_text": {
    "status": "handled",
    "how": "intro and message wrap; the masked address never wraps, so keep it short",
    "evidence": ".odl-head strong { color: var(--ds-color-text-primary); font-weight: var(--ds-font-weight-label); white-space: nowrap; }"
   },
   "missing_image": {
    "status": "none",
    "how": "the part has no photo"
   }
  }
 },
 "tokens": [
  "--ds-border-width-default",
  "--ds-border-width-emphasis",
  "--ds-color-bg-action-primary",
  "--ds-color-bg-action-primary-hover",
  "--ds-color-bg-disabled",
  "--ds-color-bg-field",
  "--ds-color-bg-neutral-subtle",
  "--ds-color-border-danger",
  "--ds-color-border-default",
  "--ds-color-border-focus",
  "--ds-color-border-input",
  "--ds-color-border-separator",
  "--ds-color-border-strong",
  "--ds-color-border-subtle",
  "--ds-color-icon-default",
  "--ds-color-surface-raised",
  "--ds-color-text-danger",
  "--ds-color-text-disabled",
  "--ds-color-text-link",
  "--ds-color-text-on-action",
  "--ds-color-text-primary",
  "--ds-color-text-secondary",
  "--ds-elevation-raised",
  "--ds-focus-ring-offset",
  "--ds-focus-ring-width",
  "--ds-font-family-mono",
  "--ds-font-weight-body",
  "--ds-font-weight-label",
  "--ds-icon-stroke-md",
  "--ds-motion-duration-short",
  "--ds-motion-easing-standard",
  "--ds-radius-12",
  "--ds-radius-container",
  "--ds-radius-control",
  "--ds-radius-detail",
  "--ds-radius-full",
  "--ds-size-control-lg",
  "--ds-size-control-md",
  "--ds-size-icon-md",
  "--ds-size-icon-sm",
  "--ds-size-target-min",
  "--ds-space-12",
  "--ds-space-2",
  "--ds-space-inline-sm",
  "--ds-space-inset-lg",
  "--ds-space-inset-md",
  "--ds-space-inset-xl",
  "--ds-space-stack-lg",
  "--ds-space-stack-md",
  "--ds-space-stack-sm",
  "--ds-text-body-md",
  "--ds-text-label-lg",
  "--ds-text-label-md",
  "--ds-text-title-lg"
 ],
 "a11y": {
  "summary": "The boxes are a labelled group, each input says which digit it is and points to the message, arrows and Backspace move between boxes, the first box offers one-time-code autofill, and the message is a polite live region.",
  "roles": [
   "region"
  ],
  "keyboard": [
   "Typing a digit fills the box and moves to the next one",
   "Pasting a code fills all the boxes at once",
   "Backspace in an empty box clears the box before it and moves there",
   "Left and Right arrows move between boxes",
   "Tab moves from the boxes to Verify, then Resend when it is ready, then Use a different email; Enter or Space presses the focused button"
  ],
  "controls": {
   "button": 3,
   "input": 6,
   "link": 0,
   "select": 0,
   "textarea": 0,
   "summary": 0
  },
  "focus_visible": true,
  "reduced_motion": true,
  "min_target": true
 },
 "files": {
  "html": "components/code-input/component.html",
  "bytes": 12792,
  "script": true
 },
 "source": null,
 "photos": 0,
 "urls": {
  "html": "https://opendesigner.dev/library/code-input.html",
  "json": "https://opendesigner.dev/library/code-input.json",
  "page": "https://opendesigner.dev/library/code-input/"
 },
 "get": {
  "curl": "curl -fsSLo code-input.html https://opendesigner.dev/library/code-input.html",
  "opendesigner": "python3 path/to/skills/opendesigner/scripts/library.py add code-input --from https://opendesigner.dev",
  "prompt": "Add the OpenDesigner component code-input to this project: https://opendesigner.dev/library/code-input.html. Keep its markup and states; map its --ds-* variables to my tokens."
 }
}
