<script> import {PinInput} from 'ui-ingredients';</script><Field.Root> <PinInput.Root> <PinInput.Label>Label</PinInput.Label> <PinInput.Input index={0} /> <PinInput.Input index={1} /> <PinInput.Input index={2} /> <PinInput.Input index={3} /> <PinInput.HiddenInput /> </PinInput.Root> <Field.HelperText>This is a helper text</Field.HelperText> <Field.ErrorText>This is an error text</Field.ErrorText></Field.Root>
API Reference
Root
Prop
Default
Description
autoFocus
booleanWhether to auto-focus the first input.
blurOnComplete
booleanWhether to blur the input when the value is complete
count
numberThe number of inputs to render to improve SSR aria attributes.
This will be required in next major version.
defaultValue
string[]The initial value of the the pin input when rendered.
Use when you don't need to control the value of the pin input.
disabled
booleanWhether the inputs are disabled
form
stringThe associate form of the underlying input element.
id
stringThe unique identifier of the machine.
ids
{
root?: string;
hiddenInput?: string;
label?: string;
control?: string;
input(id: string)?: string;
}The ids of the elements in the pin input. Useful for composition.
invalid
booleanWhether the pin input is in the invalid state
mask
booleanIf `true`, the input's value will be masked just like `type=password`
name
stringThe name of the input element. Useful for form submission.
onValueChange
(details: ValueChangeDetails) => voidFunction called on input change
onValueComplete
(details: ValueChangeDetails) => voidFunction called when all inputs have valid values
onValueInvalid
(details: ValueInvalidDetails) => voidFunction called when an invalid value is entered
otp
booleanIf `true`, the pin input component signals to its fields that they should
use `autocomplete="one-time-code"`.
pattern
stringThe regular expression that the user-entered input value is checked against.
placeholder
"â—‹"
stringThe placeholder text for the input
readOnly
booleanWhether the pin input is in the valid state
required
booleanWhether the pin input is required
selectOnFocus
booleanWhether to select input value when input is focused
translations
IntlTranslationsSpecifies the localized strings that identifies the accessibility elements and their states
type
"numeric"
"alphanumeric" | "numeric" | "alphabetic"The type of value the pin-input should allow
value
string[]The controlled value of the the pin input.
asChild
SnippetRender a different element.
Data Attribute
Value
data-complete
Present when the pin-input value is complete
data-disabled
Present when disabled
data-invalid
Present when invalid
data-part
root
data-readonly
Present when read-only
data-scope
pin-input
ClearTrigger
Prop
Default
Description
asChild
SnippetRender a different element.
Control
Prop
Default
Description
asChild
SnippetRender a different element.
HiddenInput
Prop
Default
Description
asChild
SnippetRender a different element.
Input
Prop
Default
Description
index
numberThe index of the input in the pin input.
asChild
SnippetRender a different element.
Data Attribute
Value
data-complete
Present when the input value is complete
data-disabled
Present when disabled
data-index
The index of the item
data-invalid
Present when invalid
data-part
input
data-scope
pin-input
Label
Prop
Default
Description
asChild
SnippetRender a different element.
Data Attribute
Value
data-complete
Present when the label value is complete
data-disabled
Present when disabled
data-invalid
Present when invalid
data-part
label
data-readonly
Present when read-only
data-scope
pin-input
Accessibility
Keyboard Support
Key
Description
ArrowLeft
Moves focus to the previous input
ArrowRight
Moves focus to the next input
Backspace
Deletes the value in the current input and moves focus to the previous input