import { TextField } from "@vortexlabs/vortex-native";
<TextField.Root
size="md"
variant="outline"
disabled={false}
error={false}
gap={2}
>
<TextField.Label>Email address</TextField.Label>
<TextField.Input
name="email"
type="email"
placeholder="you@example.com"
/>
<TextField.ErrorMessage>Enter a valid email address.</TextField.ErrorMessage>
</TextField.Root>Features
- Composes a single-line input with a label and messages.
- Supports keyboard presets, secure entry, and return-key actions.
- Accepts icons, affixes, or custom slots on either side.
Anatomy
<TextField.Root>
<TextField.Label>Email address</TextField.Label>
<TextField.Input name="email" />
<TextField.HelperText>We will use this address for project updates.</TextField.HelperText>
<TextField.ErrorMessage>Enter a valid value.</TextField.ErrorMessage>
</TextField.Root>error is set.Variants and Sizes
Use variant="fill" for a filled surface. Set size on the root to size the input and its spacing.
<Stack gap={4}>
<TextField.Root variant="outline" size="sm">
<TextField.Label>First name</TextField.Label>
<TextField.Input name="firstName" />
</TextField.Root>
<TextField.Root variant="fill" size={{ xs: "sm", md: "md" }}>
<TextField.Label>Last name</TextField.Label>
<TextField.Input name="lastName" />
</TextField.Root>
</Stack>Affixes
Use a prefix or suffix for units that stay visible while people edit the value.
<TextField.Root>
<TextField.Label>Travel budget</TextField.Label>
<TextField.Input name="budget" type="number" prefix="$" suffix="USD" />
<TextField.HelperText>Enter the total for the trip.</TextField.HelperText>
</TextField.Root>Custom Slots
Use a custom slot for an action inside the field. Each side accepts a slot or its built-in icon and affix.
import { TextField, Button } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const PasswordField = () => {
const [visible, setVisible] = useState(false);
return (
<TextField.Root>
<TextField.Label>Password</TextField.Label>
<TextField.Input
name="password"
type="password"
secureTextEntry={!visible}
autoComplete="current-password"
endSlot={
<Button size="sm" variant="tertiary" onPress={() => setVisible(!visible)}>
{visible ? "Hide" : "Show"}
</Button>
}
/>
</TextField.Root>
);
};Keyboard and Submission
Use returnKeyType="next" to label the return key. Use the input ref to focus the next field in onSubmit.
import { TextField, Stack } from "@vortexlabs/vortex-native";
import { useRef } from "react";
import type { TextInputInstance } from "react-native";
export const SignInFields = () => {
const passwordRef = useRef<TextInputInstance>(null);
return (
<Stack gap={4}>
<TextField.Root>
<TextField.Label>Email address</TextField.Label>
<TextField.Input
name="email"
type="email"
autoComplete="email"
returnKeyType="next"
attributes={{ submitBehavior: "submit" }}
onSubmit={() => passwordRef.current?.focus()}
/>
</TextField.Root>
<TextField.Root>
<TextField.Label>Password</TextField.Label>
<TextField.Input
name="password"
ref={passwordRef}
type="password"
autoComplete="current-password"
returnKeyType="done"
/>
</TextField.Root>
</Stack>
);
};Controlled Value and Validation
Update the controlled input from onChange. Set error on the root to show TextField.ErrorMessage.
import { TextField } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const DisplayName = () => {
const [name, setName] = useState("");
const [touched, setTouched] = useState(false);
return (
<TextField.Root error={touched && name.trim().length === 0}>
<TextField.Label>Display name</TextField.Label>
<TextField.Input
name="displayName"
value={name}
onChange={({ value }) => setName(value)}
onBlur={() => setTouched(true)}
/>
<TextField.ErrorMessage>Enter a display name.</TextField.ErrorMessage>
</TextField.Root>
);
};Disabled and Read Only
Set disabled on the root to mark the field unavailable. Set attributes.readOnly on the input to keep its value visible without editing.
<Stack gap={4}>
<TextField.Root disabled>
<TextField.Label>Assigned reviewer</TextField.Label>
<TextField.Input name="reviewer" placeholder="Unassigned" />
</TextField.Root>
<TextField.Root>
<TextField.Label>Project ID</TextField.Label>
<TextField.Input name="projectId" defaultValue="PRJ-1042" attributes={{ readOnly: true }} />
</TextField.Root>
</Stack>Accessibility
attributes["aria-label"].