---
title: PinInput
description: "`PinInput` is a component used to capture pin codes or OTP (One-Time Password) inputs."
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/pin-input/pin-input.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/pin-input
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-pininput--basic
---
```tsx
```
## Usage
```tsx
import { PinInput } from "@yamada-ui/react"
```
```tsx
import { PinInput } from "@/components/ui"
```
```tsx
import { PinInput } from "@workspaces/ui"
```
```tsx
```
### Change Variant
```tsx
{(variant) => }
```
### Change Size
```tsx
{(size) => }
```
### Change Color Scheme
```tsx
{(colorScheme) => (
)}
```
### Set Default Value
To set a default value, set a string to `defaultValue`.
```tsx
{(defaultValue) => (
)}
```
### Change Placeholder
To change the placeholder, set a string to `placeholder`.
```tsx
```
### Change Number of Fields
To change the number of fields, set a number to `items`.
```tsx
{(items) => }
```
### Change Type
By default, only numeric input is allowed. To support alphanumeric, set `type` to `alphanumeric`.
```tsx
```
### Use as One-Time Password
To use as a one-time password (`autocomplete="one-time-code"`), set `otp` to `true`.
```tsx
```
### Mask Entered Value
To mask the entered value, set `mask` to `true`.
```tsx
```
### Disabled
To disable the input, set `disabled` to `true`.
```tsx
{(index) => }
```
### Read-Only
To make read-only, set `readOnly` to `true`.
```tsx
{(index) => }
```
### Invalid
To make invalid, set `invalid` to `true`.
```tsx
{(index) => }
```
### Change Border Color
To change the border color, set `focusBorderColor` or `errorBorderColor` to the color.
```tsx
```
### Set Action on Completion
To set the action on completion, use the `onComplete` property.
```tsx
const { page } = useLoading()
return page.start({ duration: 5000 })} />
```
### Disable Focus Management
By default, when a field is entered, the focus automatically moves to the next field. Also, when the `BackSpace` key is pressed, the focus moves to the previous field. To disable this control, set `manageFocus` to `false`.
```tsx
```
### Customize Field
```tsx
{(index) => (
)}
```
### Control
```tsx
const { page } = useLoading()
const [value, onChange] = useState("")
const onComplete = () => page.start({ duration: 5000 })
return (
)
```
## Props
### PinInput.Root
| Prop | Default | Type | Description |
| ------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | `"md"` | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `variant` | `"outline"` | `"filled" \| "flushed" \| "outline" \| "plain"` | The variant of the component. |
| `align` | - | `"-moz-initial" \| "baseline" \| "center" \| "end" \| "flex-end" \| "flex-start" \| "inherit" \| "initial" \| "normal" \| "revert-layer" ...` | The CSS `align-items` property. |
| `attached` | `false` | `boolean` | If `true`, the borderRadius of button that are direct children will be altered to look flushed together. |
| `basis` | - | `"-moz-fit-content" \| "-moz-initial" \| "-moz-max-content" \| "-moz-min-content" \| "-webkit-auto" \| "0.5" \| "1.5" \| "1" \| "1/12" \| "1/2" ...` | The CSS `flex-basis` property. |
| `defaultValue` | - | `string` | The initial value of the pin input. |
| `direction` | - | `"-moz-initial" \| "column-reverse" \| "column" \| "inherit" \| "initial" \| "revert-layer" \| "revert" \| "row-reverse" \| "row" \| "unset" ...` | The CSS `flex-direction` property. |
| `disabled` | `false` | `boolean` | If `true`, the field will be disabled. |
| `errorBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is invalid. |
| `focusBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is focused. |
| `grow` | `false` | `boolean` | If `true`, the children will grow to fill the available space. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `items` | `4` | `number` | The number of inputs to display. |
| `justify` | - | `"-moz-initial" \| "center" \| "end" \| "flex-end" \| "flex-start" \| "inherit" \| "initial" \| "left" \| "normal" \| "revert-layer" ...` | The CSS `justify-content` property. |
| `manageFocus` | `true` | `boolean` | If `true`, focus will move automatically to the next input once filled. |
| `mask` | - | `boolean` | If `true`, the input's value will be masked just like `type=password`. |
| `onChange` | - | `(value: string) => void` | Function called on input change. |
| `onComplete` | - | `(value: string) => void` | Function called when all inputs have valid values. |
| `orientation` | `"horizontal"` | `"horizontal" \| "vertical"` | The orientation of the group. |
| `otp` | - | `boolean` | If `true`, the pin input component signals to its fields that they should. |
| `placeholder` | `"â—¯"` | `string` | The placeholder for the pin input. |
| `readOnly` | `false` | `boolean` | If `true`, the field will be readonly. |
| `required` | `false` | `boolean` | If `true`, the field will be required. |
| `shrink` | - | `"-moz-initial" \| "inherit" \| "initial" \| "revert-layer" \| "revert" \| "unset" \| number & {} ...` | The CSS `flex-shrink` property. |
| `stacking` | - | `"first-on-top" \| "last-on-top"` | The stacking order of the group. |
| `type` | `"number"` | `"alphanumeric" \| "number"` | The type of values the pin-input should allow. |
| `value` | - | `string` | The value of the pin input. |
| `wrap` | - | `"-moz-initial" \| "inherit" \| "initial" \| "nowrap" \| "revert-layer" \| "revert" \| "unset" \| "wrap-reverse" \| "wrap" ...` | The CSS `flex-wrap` property. |
### PinInput.Field
| Prop | Default | Type | Description |
| ------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | - | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `variant` | - | `"filled" \| "flushed" \| "outline" \| "plain"` | The variant of the component. |
| `index` | - | `number` | The index of the pin input field. |
| `errorBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is invalid. |
| `focusBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is focused. |
| `htmlSize` | - | `number` | The native HTML `size` attribute to be passed to the `input`. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
## Accessibility
Currently, this section is being updated due to the migration of v2.