SecureField
Platform password entry with autofill and fixed redaction.
- Native host
- In the first release
import { SecureField, secureFieldPrimitive } from "nitro-ui-sdk/secure-field";- HeroUI Native
- TextField (secure)
- Expo UI
- SecureField

Light 
Dark
On this page
SecureField uses the platform password editor for a saved or new password. Use TextField for ordinary text and InputOTP for one-time codes.
Anatomy
import { SecureField } from "nitro-ui-sdk/secure-field";
<SecureField.Root label="Password">
<SecureField.Label />
<SecureField.Editor />
<SecureField.Hint />
<SecureField.Error />
</SecureField.Root>;
| Part | Description |
|---|---|
Root |
Owns the password value and optional native focus controller. |
Label |
Visible field name. |
Editor |
Secure native editor. |
Hint |
Helper text. |
Error |
Validation message. |
Usage
import { SecureField } from "nitro-ui-sdk/secure-field";
<SecureField.Root label="New password" passwordKind="new-password" passwordRules="minlength: 12;" />;
Variants and sizes
Choose outline for a 1 pt field border or filled for a secondary surface. The visible heights are 36 pt (sm), 44 pt (md), and 52 pt (lg). Compact one-line fields keep a 44 pt touch target. Set passwordKind to choose between saved-password and new-password autofill.
States
The focused editor uses the focus border. Invalid fields use the danger border. Disabled fields reduce opacity and reject editing actions.
Controlled
Pass defaultValue for a local value or value with onValueChange to own it. The editor reconciles to the owner’s value after each edit, including a declined request.
import { useState } from "react";
import { SecureField } from "nitro-ui-sdk/secure-field";
export function Example() {
const [value, setValue] = useState("");
return <SecureField.Root label="Password" value={value} onValueChange={setValue} />;
}
Props
SecureField.Root
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string |
Required | Localized name spoken by assistive technology. |
hint |
string |
— | Additional instructions spoken with the field. |
error |
string |
— | Validation message spoken with the field. |
invalid |
boolean |
false |
Applies the invalid appearance. A nonempty error also marks it invalid. |
disabled |
boolean |
false |
Disables editing and reduces opacity. |
variant |
SecureFieldVariant |
"outline" |
Field surface appearance. |
size |
SecureFieldSize |
"md" |
Visible field size. |
value |
string |
— | Owner-controlled text. |
defaultValue |
string |
"" |
Initial text in uncontrolled mode. |
onValueChange |
(value: string, details: ActionDetails) => void |
— | Receives the requested text. Call details.preventDefault() to decline. |
onValueCommit |
(value: string, details: ActionDetails) => void |
— | Runs once per accepted edit that changes the value. |
placeholder |
string |
— | Native placeholder. |
passwordKind |
SecureFieldPasswordKind |
"current-password" |
Credential autofill mode, independent of appearance. |
passwordRules |
string |
— | iOS password-rules descriptor for new-password suggestions. |
onSubmit |
(value: string, details: ActionDetails) => void |
— | Receives the password from a native Return interaction. |
styles |
PartStyles<SecureFieldPart, SecureFieldVariant, SecureFieldSize, SecureFieldState> |
— | Style resolvers keyed by part. |
api |
Controller<SecureFieldActions> |
— | Attach a controller created with the primitive. |
agentId |
string |
— | Identity for replacing a field in a reused view. |
children |
ReactNode |
— | Compound anatomy override. |
SecureField.Label, SecureField.Hint and SecureField.Error
| Prop | Type | Default | Description |
|---|---|---|---|
part |
SecureFieldPart |
— | Override the style key for this part. |
children |
string |
Root text | Visible text for this part. |
SecureField.Editor
| Prop | Type | Default | Description |
|---|---|---|---|
part |
SecureFieldPart |
— | Override the style key for this part. |
Controller API
import { SecureField, secureFieldPrimitive } from "nitro-ui-sdk/secure-field";
const api = secureFieldPrimitive.createApi();
const field = <SecureField.Root label="Password" api={api} />;
// Use api.current after the field mounts.
export { field, api };
| Action | Signature | Result |
|---|---|---|
focus |
(source?: ActionSource) => ActionStatus |
Focuses the editor when it is available. |
blur |
(source?: ActionSource) => ActionStatus |
Dismisses native editing. |
Styles
import { SecureField } from "nitro-ui-sdk/secure-field";
<SecureField.Root label="Password" styles={{ editor: ({ tokens }) => ({ style: { cornerRadius: tokens.radius.card } }) }} />;
Resolvers receive tokens, variant, size, and state. State includes disabled, invalid, and focused.
Accessibility
The native editor speaks label as its name and reads error before hint. Editing, selection and dictation are platform-owned. The OS applies secure-entry behavior. Keep the password out of labels, hints and validation messages.
Agent API
| Action | Arguments | Notes |
|---|---|---|
focus |
None | The field value is always redacted. Only focus is discoverable. |
Platform notes
| iOS | Android | |
|---|---|---|
| Implementation | Secure UIKit text field with password autofill and password rules. | Password EditText with Autofill Manager hints. |
| Verification | Native iOS harness in the example app. | Kotlin is written for Android. The Android NDK is unavailable on this machine, so no Android build was run. |