{
  "package": "@blade-ai/weft",
  "status": "stable",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "component": "PasswordInput",
  "import": "import { PasswordInput } from \"@blade-ai/weft/components/password-input\";",
  "iconsImport": "import { EyeIcon, EyeOffIcon } from \"@blade-ai/weft/components/icons\";",
  "docs": "/components/password-input",
  "description": "A masked single-line field with a show / hide toggle, help text and validation. One size (medium); square, flat and token-driven.",
  "props": [
    {
      "name": "label",
      "type": "string",
      "default": "Password",
      "required": true,
      "description": "Visible label rendered with <label htmlFor>."
    },
    {
      "name": "labelPosition",
      "type": "\"top\" | \"left\"",
      "values": [
        "top",
        "left"
      ],
      "default": "top",
      "required": false,
      "description": "'left' = 120px label column beside the input."
    },
    {
      "name": "placeholder",
      "type": "string",
      "default": null,
      "required": false,
      "description": "UNDEFINED · needs decision (inherited; never drawn). Not exposed."
    },
    {
      "name": "value · defaultValue",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Controlled or uncontrolled; masked with • unless visible. Never trimmed."
    },
    {
      "name": "onChange",
      "type": "(value: string) => void",
      "default": null,
      "required": false,
      "description": "Called with the new value."
    },
    {
      "name": "onBlur",
      "type": "(event: FocusEvent) => void",
      "default": null,
      "required": false,
      "description": "Validate here, not on every keystroke."
    },
    {
      "name": "visible",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "true = plain text (type=\"text\"). Controlled when provided."
    },
    {
      "name": "onVisibleChange",
      "type": "(visible: boolean) => void",
      "default": null,
      "required": false,
      "description": "Called when the toggle is pressed."
    },
    {
      "name": "showToggle",
      "type": "boolean",
      "default": true,
      "required": false,
      "description": "Eye / EyeOff ghost button, 28 × 28."
    },
    {
      "name": "validationState",
      "type": "\"none\" | \"error\" | \"success\"",
      "values": [
        "none",
        "error",
        "success"
      ],
      "default": "none",
      "required": false,
      "description": "'error' sets aria-invalid; error text replaces help text."
    },
    {
      "name": "helpText · errorText · successText",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Help is recommended. Error is prefixed \"! \", success \"✓ \"."
    },
    {
      "name": "necessityIndicator",
      "type": "\"none\" | \"required\" | \"optional\"",
      "values": [
        "none",
        "required",
        "optional"
      ],
      "default": "none",
      "required": false,
      "description": "'required' adds * and aria-required. 'optional' copy: UNDEFINED · needs decision (renders nothing extra)."
    },
    {
      "name": "isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Disables the toggle too."
    },
    {
      "name": "isLoading",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "UNDEFINED · needs decision (inherited; drawn from Text Input). Spinner before the toggle, aria-busy."
    },
    {
      "name": "autoComplete",
      "type": "\"current-password\" | \"new-password\"",
      "values": [
        "current-password",
        "new-password"
      ],
      "default": "current-password",
      "required": false,
      "description": "'new-password' on sign-up and change."
    },
    {
      "name": "readOnly · capsLockWarning · toggleLabel · labelWidth",
      "type": "—",
      "default": null,
      "required": false,
      "description": "UNDEFINED · needs decision. Not built."
    },
    {
      "name": "size",
      "type": "\"medium\"",
      "default": "medium",
      "required": false,
      "description": "36px. Small / large: UNDEFINED · needs decision. Not exposed."
    }
  ],
  "states": [
    {
      "name": "default (empty)",
      "trigger": "First render, value = \"\", not focused",
      "tokens": "bg surface.background.gray.subtle · border interactive.border.gray.default · toggle icon surface.text.gray.muted · label surface.text.gray.normal · help surface.text.gray.muted",
      "notes": "Placeholder: UNDEFINED · needs decision."
    },
    {
      "name": "hover",
      "trigger": "Pointer over the field, not disabled",
      "tokens": "border interactive.border.gray.highlighted",
      "notes": "Not applied while focused, invalid or disabled."
    },
    {
      "name": "focus-visible",
      "trigger": "Input focused",
      "tokens": "border interactive.border.primary.default · ring 3px interactive.border.primary.faded",
      "notes": "—"
    },
    {
      "name": "filled · hidden",
      "trigger": "value.length > 0, visible = false",
      "tokens": "masked value surface.text.gray.normal (• per character) · toggle icon Eye",
      "notes": "—"
    },
    {
      "name": "filled · visible",
      "trigger": "visible = true",
      "tokens": "plain value surface.text.gray.normal · toggle icon EyeOff",
      "notes": "type switches to text; toggle aria-pressed=\"true\"."
    },
    {
      "name": "toggle hover / focus-visible",
      "trigger": "Pointer over / Tab onto the toggle",
      "tokens": "hover: toggle bg surface.background.gray.moderate · focus: toggle border surface.text.gray.normal + ring 3px interactive.border.primary.faded",
      "notes": "Toggle icon colour on hover and focus style: UNDEFINED · needs decision. The Agent Spec names interactive.background.gray.default / interactive.border.primary.default; the Paper artboard draws the tokens used here."
    },
    {
      "name": "loading",
      "trigger": "isLoading",
      "tokens": "spinner 16px surface.icon.gray.muted, before the toggle · aria-busy",
      "notes": "Loading at all: UNDEFINED · needs decision."
    },
    {
      "name": "success",
      "trigger": "validationState = success",
      "tokens": "border interactive.border.gray.default (unchanged) · help text feedback.text.positive.intense + \"✓ \"",
      "notes": "Success border / bg: UNDEFINED · needs decision."
    },
    {
      "name": "invalid / error",
      "trigger": "validationState = error",
      "tokens": "border feedback.border.negative.intense · error text feedback.text.negative.intense, prefixed \"! \"",
      "notes": "Error text replaces help text. Toggle keeps working. The Paper artboard draws the border with feedback.text.negative.intense; the Agent Spec and Tokens table name feedback.border.negative.intense, which is built."
    },
    {
      "name": "disabled",
      "trigger": "isDisabled",
      "tokens": "bg interactive.background.gray.disabled · border interactive.border.gray.default · opacity.600 on the whole field",
      "notes": "Toggle disabled too. No hover, focus or caret."
    },
    {
      "name": "caps lock on",
      "trigger": "Caps Lock on while focused",
      "tokens": "UNDEFINED · needs decision",
      "notes": "Not built."
    },
    {
      "name": "read-only",
      "trigger": "readOnly = true",
      "tokens": "UNDEFINED · needs decision",
      "notes": "Not built."
    }
  ],
  "sizes": [
    {
      "property": "Height",
      "value": "36px (medium only)",
      "token": "size.36"
    },
    {
      "property": "Horizontal padding",
      "value": "left 12px · right 4px",
      "token": "spacing.4 · spacing.2"
    },
    {
      "property": "Gap (value ↔ spinner ↔ toggle)",
      "value": "6px",
      "token": "spacing.15"
    },
    {
      "property": "Visibility toggle",
      "value": "28 × 28px · icon 16px",
      "token": "size.28 · size.16 · surface.text.gray.muted"
    },
    {
      "property": "Value / label",
      "value": "13px / 20px / 400",
      "token": "fonts.size.1200 · lineHeights.100 · fonts.family.text"
    },
    {
      "property": "Label ↔ input ↔ help gap",
      "value": "top: 8px · left: 12px",
      "token": "spacing.3 · spacing.4"
    },
    {
      "property": "Help / error / success text",
      "value": "12px / 16px · tracking 0.01em",
      "token": "fonts.size.75 · lineHeights.50 · letterSpacings.200"
    },
    {
      "property": "Left label column",
      "value": "120px",
      "token": "no token; Text Input sheet uses 80px (labelWidth: UNDEFINED · needs decision)"
    },
    {
      "property": "Border · ring · radius",
      "value": "1px · 3px · 0",
      "token": "border.width.thin · interactive.border.primary.faded + border.width.3 · border.radius.none"
    },
    {
      "property": "Disabled opacity",
      "value": "50%",
      "token": "opacity.600"
    }
  ],
  "behaviour": {
    "input": "A native <input> whose type is password until visible is true, plus a toggle <button> inside the field frame, labelled by <label htmlFor>.",
    "validation": "Validate on blur or submit, not on every keystroke. Error text replaces help text; never show both.",
    "toggle": "Click flips visible and calls onVisibleChange(visible); caret position is kept. Auto-hide on submit or after a timeout: UNDEFINED · needs decision.",
    "loading": "Spinner sits before the toggle; the toggle stays usable. Loading itself is undecided.",
    "capsLock": "Warning text, position and token: UNDEFINED · needs decision. Not built.",
    "paste": "Paste is kept as-is (no format). Never block paste (password managers). Never trim the value.",
    "autofill": "autoComplete 'current-password' on sign-in, 'new-password' on sign-up and change. Autofill highlight: UNDEFINED · needs decision.",
    "error": "Set validationState='error' + errorText; keep the value and focus. After the first blur or submit, re-validate on every change and clear the error as soon as the value is valid.",
    "autoFocus": "autoFocus targets the password input itself, never the visibility toggle.",
    "strength": "Rules live in helpText. Strength meter / live rule checklist: UNDEFINED · needs decision."
  },
  "keyboard": [
    {
      "key": "Any character",
      "action": "Types at the caret."
    },
    {
      "key": "Backspace / Delete",
      "action": "Deletes before / after the caret."
    },
    {
      "key": "← / → · Home / End",
      "action": "Moves the caret."
    },
    {
      "key": "Cmd / Ctrl + V",
      "action": "Pastes at the caret."
    },
    {
      "key": "Tab / Shift + Tab",
      "action": "Input → toggle → next field (the toggle is a native button in the tab order)."
    },
    {
      "key": "Space / Enter on toggle",
      "action": "Shows or hides the password; focus stays on the toggle."
    },
    {
      "key": "Enter",
      "action": "In the input: native form submit. No extra behaviour."
    }
  ],
  "accessibility": {
    "summary": "Native text input plus a native toggle button; the <input> carries the name, description and state.",
    "aria": [
      {
        "element": "<input>",
        "attributes": "native textbox · id linked from <label htmlFor>",
        "when": "Always"
      },
      {
        "element": "<input>",
        "attributes": "aria-describedby=\"{messageId}\"",
        "when": "Help, success or error text is shown"
      },
      {
        "element": "<input>",
        "attributes": "aria-invalid=\"true\"",
        "when": "validationState = error"
      },
      {
        "element": "<input>",
        "attributes": "aria-busy=\"true\"",
        "when": "isLoading"
      },
      {
        "element": "<input>",
        "attributes": "aria-required=\"true\" · required · disabled",
        "when": "necessityIndicator = required · isDisabled"
      },
      {
        "element": "Visibility toggle",
        "attributes": "<button type=\"button\" aria-label=\"Show password\" | \"Hide password\" aria-pressed={visible} aria-controls={inputId}>",
        "when": "showToggle = true"
      },
      {
        "element": "Eye / EyeOff icon · spinner",
        "attributes": "aria-hidden=\"true\"",
        "when": "Always"
      },
      {
        "element": "Caps Lock warning",
        "attributes": "aria-live=\"polite\" region: UNDEFINED · needs decision",
        "when": "Caps Lock on while focused"
      }
    ]
  },
  "usage": {
    "do": [
      "Always show a visible label (\"Password\") and the rules in helpText.",
      "Keep showToggle on so people can check what they typed.",
      "Use autoComplete 'current-password' to sign in and 'new-password' to sign up or change.",
      "Validate on blur or submit, and replace help text with the error."
    ],
    "dont": [
      "Block paste or trim the value.",
      "Show help text and error text at the same time.",
      "Reveal the password by default (visible = false).",
      "Add a clear button; the trailing slot belongs to the toggle.",
      "Use Password Input for OTP codes; use OTP Input."
    ]
  },
  "example": "<PasswordInput label=\"Password\" autoComplete=\"new-password\" helpText=\"Use 8+ characters with a number and a symbol.\" validationState={error ? \"error\" : \"none\"} errorText={error} onChange={setPassword} onBlur={validate} />"
}
