Files
gsfdc/demo-dify/dify/packages/dify-ui/src/password-field/README.md
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

1.7 KiB

Password Field

Use PasswordField for a password the user types and may reveal to check. It renders the Input Group surface, so the shared border, background, focus, invalid, and disabled visuals are the same as every other grouped input.

Anatomy

<Field name="password">
  <FieldLabel>Password</FieldLabel>
  <PasswordField>
    <PasswordFieldInput autoComplete="current-password" required />
    <PasswordFieldToggle aria-label="Show password" />
  </PasswordField>
</Field>

The anatomy mirrors the Base UI Password Field preview. Dify UI owns the appearance and this public API: the surface, the input styles, the toggle's size and glyph. The reveal behavior is a minimal local implementation until Base UI ships the primitive; the parts then become styled wrappers around it without changing call sites.

Contract

  • PasswordFieldInput owns type. autoComplete is required: current-password for an existing password, new-password for a password being set.
  • PasswordFieldToggle is optional. Its aria-label stays constant; aria-pressed reports whether the value is revealed. Pressing it with a pointer keeps focus in the input. It stays available while the input is read-only.
  • disabled on PasswordField applies to the input and the toggle; a disabled Field reaches only the input. Wrap the field in Field for the label, validation, and errors.
  • Other masked values, such as tokens, use Input with type="password" and autoComplete="off". new-password would make browsers suggest a generated password for them.