import { PinField } from "@vortexlabs/vortex-native";
<PinField.Root
size="md"
variant="outline"
disabled={false}
error={false}
>
<PinField.Label>Verification code</PinField.Label>
<PinField.Input
name="verification"
length={4}
pattern="numeric"
/>
<PinField.ErrorMessage>The code has expired.</PinField.ErrorMessage>
</PinField.Root>Features
- Displays a short code in a row of cells.
- Supports numeric, alphabetic, and alphanumeric codes.
- Accepts typed or pasted input and reports when all cells are filled.
- Supports controlled values, disabled fields, and validation messages.
Anatomy
<PinField.Root>
<PinField.Label>Verification code</PinField.Label>
<PinField.Input name="verification" />
<PinField.HelperText>Use the code from your email.</PinField.HelperText>
<PinField.ErrorMessage>The code has expired.</PinField.ErrorMessage>
</PinField.Root>Sizes
Set the cell size on PinField.Root. Use a breakpoint map when the field needs to fit different pane widths.
import { PinField, Stack } from "@vortexlabs/vortex-native";
export const PinFieldSizes = () => (
<Stack gap={4}>
<PinField.Root size="sm">
<PinField.Label>Small</PinField.Label>
<PinField.Input name="smallCode" />
</PinField.Root>
<PinField.Root size="md">
<PinField.Label>Medium</PinField.Label>
<PinField.Input name="mediumCode" />
</PinField.Root>
<PinField.Root size="lg">
<PinField.Label>Large</PinField.Label>
<PinField.Input name="largeCode" />
</PinField.Root>
</Stack>
);Variants
Use outline for bordered cells or fill for filled cells.
import { PinField, Stack } from "@vortexlabs/vortex-native";
export const PinFieldVariants = () => (
<Stack gap={4}>
<PinField.Root variant="outline">
<PinField.Label>Outline</PinField.Label>
<PinField.Input name="outlineCode" />
</PinField.Root>
<PinField.Root variant="fill">
<PinField.Label>Fill</PinField.Label>
<PinField.Input name="fillCode" />
</PinField.Root>
</Stack>
);Length
Set length to match the code you issue. The input accepts pasted codes and requests one-time-code autofill from the platform. Use defaultValue to prefill an uncontrolled field.
import { PinField, Stack } from "@vortexlabs/vortex-native";
export const PinFieldLength = () => (
<Stack>
<PinField.Root size="sm">
<PinField.Label>Six-digit verification code</PinField.Label>
<PinField.Input name="sixDigitCode" length={6} />
</PinField.Root>
</Stack>
);Character Patterns
The default numeric opens the number pad. Use alphabetic for A–Z in either case, or alphanumeric for A–Z and digits. The input filters out other characters.
import { PinField, Stack } from "@vortexlabs/vortex-native";
export const PinFieldPatterns = () => (
<Stack gap={4}>
<PinField.Root>
<PinField.Label>Office code</PinField.Label>
<PinField.Input name="officeCode" pattern="alphabetic" defaultValue="DESK" />
</PinField.Root>
<PinField.Root>
<PinField.Label>Booking code</PinField.Label>
<PinField.Input name="bookingCode" pattern="alphanumeric" defaultValue="A1B2" />
</PinField.Root>
</Stack>
);Controlled State
Pass value and update it in onChange. Use onComplete when an edit leaves all cells filled, such as to enable Continue.
import { Button, PinField, Stack, Text } from "@vortexlabs/vortex-native";
import React from "react";
export const ControlledPinField = () => {
const [code, setCode] = React.useState("");
const [complete, setComplete] = React.useState(false);
return (
<Stack gap={3}>
<PinField.Root>
<PinField.Label>Access code</PinField.Label>
<PinField.Input
name="accessCode"
value={code}
onChange={({ value }) => {
setCode(value);
setComplete(false);
}}
onComplete={() => setComplete(true)}
/>
</PinField.Root>
{complete && <Text>Code ready to verify</Text>}
<Button
variant="secondary"
disabled={!code}
onPress={() => {
setCode("");
setComplete(false);
}}
>
Clear code
</Button>
</Stack>
);
};Disabled and Error States
Set disabled or error on the root. PinField.ErrorMessage appears while error is true.
import { PinField, Stack } from "@vortexlabs/vortex-native";
export const PinFieldStates = () => (
<Stack gap={4}>
<PinField.Root disabled>
<PinField.Label>Verified code</PinField.Label>
<PinField.Input name="verifiedCode" defaultValue="4826" />
</PinField.Root>
<PinField.Root error>
<PinField.Label>Verification code</PinField.Label>
<PinField.Input name="expiredCode" defaultValue="7352" />
<PinField.ErrorMessage>This code expired. Request a new one.</PinField.ErrorMessage>
</PinField.Root>
</Stack>
);Accessibility
attributes["aria-label"].PinField.ErrorMessage when the code is invalid.