TextField
A labeled single-line native editor with hint and error.
- Native host
- In the first release
import { TextField, textFieldPrimitive } from "nitro-ui-sdk/text-field";- HeroUI Native
- TextField
- Expo UI
- TextFieldTextInput

Light 
Dark
On this page
TextField is a labeled native single-line editor for form values. Use Input when your layout already supplies its own visible label or field messages.
Anatomy
import { TextField } from "nitro-ui-sdk/text-field";
<TextField.Root label="Email address">
<TextField.Label />
<TextField.Editor><TextField.Clear label="Clear email" /></TextField.Editor>
<TextField.Hint>Used for sign-in.</TextField.Hint>
<TextField.Error />
</TextField.Root>;
| Part | Description |
|---|---|
Root |
Owns the value and default anatomy. |
Label |
Visible field name. |
Editor |
Native editor and shared chrome. |
Clear |
Clear action, visible while enabled and nonempty. |
Hint |
Helper text. |
Error |
Validation message. |
Usage
import { TextField } from "nitro-ui-sdk/text-field";
<TextField.Root label="Email address" keyboard="email" contentType="email" />;
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.
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 { TextField } from "nitro-ui-sdk/text-field";
export function Example() {
const [value, setValue] = useState("");
return <TextField.Root label="Email address" value={value} onValueChange={setValue} />;
}
Props
TextField.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 |
TextFieldVariant |
"outline" |
Field surface appearance. |
size |
TextFieldSize |
"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. |
keyboard |
TextKeyboard |
"default" |
Native keyboard layout. |
contentType |
TextContentType |
— | Autofill hint, such as "email" or "username". |
autocapitalize |
TextCapitalization |
"sentences" |
Capitalization mode. |
autocorrect |
boolean |
true |
Use OS autocorrection. |
returnKey |
TextReturnKey |
"default" |
Native Return key label. |
maxLength |
number |
— | Maximum number of UTF-16 code units. |
onSubmit |
(value: string, details: ActionDetails) => void |
— | Receives the committed text on Return or submit. |
clearLabel |
string |
— | Localized name for the default clear button. |
styles |
PartStyles<TextFieldPart, TextFieldVariant, TextFieldSize, TextFieldState> |
— | Style resolvers keyed by part. |
api |
Controller<TextFieldActions> |
— | Attach a controller created with the primitive. |
agentId |
string |
— | Identity for replacing a field in a reused view. |
children |
ReactNode |
— | Compound anatomy override. |
TextField.Label, TextField.Hint and TextField.Error
| Prop | Type | Default | Description |
|---|---|---|---|
part |
TextFieldPart |
— | Override the style key for this part. |
children |
string |
Root text | Visible text for this part. |
TextField.Editor
| Prop | Type | Default | Description |
|---|---|---|---|
part |
TextFieldPart |
— | Override the style key for this part. |
children |
ReactNode |
— | Content to render inside this part. |
TextField.Clear
| Prop | Type | Default | Description |
|---|---|---|---|
part |
TextFieldPart |
— | Override the style key for this part. |
label |
string |
Required | Localized action name. |
children |
ReactNode |
— | Content to render inside this part. |
Controller API
import { TextField, textFieldPrimitive } from "nitro-ui-sdk/text-field";
const api = textFieldPrimitive.createApi();
const field = <TextField.Root label="Email address" 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. |
setValue |
(value: string, source?: ActionSource) => ChangeStatus |
Requests a new value. |
clear |
(source?: ActionSource) => ChangeStatus |
Requests an empty value. |
submit |
(source?: ActionSource) => ActionStatus |
Calls the submit handler with the current text. |
Controlled edits return requested while the owner renders. Agent calls resolve after that commit.
Styles
import { TextField } from "nitro-ui-sdk/text-field";
<TextField.Root label="Email address" styles={{ editor: ({ tokens }) => ({ style: { cornerRadius: tokens.radius.card } }) }} />;
Resolvers receive tokens, variant, size, and state. State includes disabled, invalid, focused, and empty.
Accessibility
The native editor speaks label as its name and reads error before hint. Editing, selection and dictation are platform-owned. Custom Hint and Error text is included with the native editor. A validation message that appears or changes after mount is announced once.
Agent API
| Action | Arguments | Notes |
|---|---|---|
focus |
None | Focus the editor. |
setValue |
String | Request a value. Controlled owners can decline. |
clear |
None | Request an empty value. |
submit |
None | Available when onSubmit is set. |
Platform notes
| iOS | Android | |
|---|---|---|
| Implementation | UIKit text field with native selection, keyboard and IME. | Android EditText with native selection, keyboard and IME. |
| 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. |