- Accordion
- Alert Dialog
- Alert
- Autocomplete
- Avatar
- Badge
- Button Group
- Button
- Card
- Carousel
- Chart
- Checkbox
- Clipboard
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Editable
- Field
- File Upload
- Floating Panel
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- QR Code
- Radio Group
- Rating Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Splitter
- Steps
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle Group
- Toggle
- Tooltip
- Tour
- Tree View
For OTP or verification codes with auto-focus transfer, blur on complete, and masking options
Installation
pnpm dlx shadcn@latest add @shark-ui/input-otp
Usage
import { InputOtp, InputOtpSeparator, InputOtpSlot, } from "@/components/ui/input-otp";
<InputOtp> <InputOtpSlot index={0} /> <InputOtpSlot index={1} /> <InputOtpSlot index={2} /> <InputOtpSeparator /> <InputOtpSlot index={3} /> <InputOtpSlot index={4} /> <InputOtpSlot index={5} /> </InputOtp>
Examples
Four Digits
Use four <InputOtpSlot /> elements for a 4-digit OTP.
Separator
Add <InputOtpSeparator /> between groups of slots.
Disabled
Use the disabled prop to disable the input.
Controlled
Use value and onValueChange to control the input.
Enter the code 1234
❌
Invalid
Use the invalid prop to mark the input as invalid and show error styling.
With Placeholder
Use the placeholder prop to show a placeholder in each slot.
Custom Size
Pass className to <InputOtp /> to override slot dimensions and text size.
Blur on Complete
Use the blurOnComplete prop to blur the input when all slots are filled.
Mask
Use the mask prop to mask the input value.
API Reference
InputOtp
| Prop | Type | Default |
|---|---|---|
withFakeCaret | boolean | false |
value | string | — |
defaultValue | string | — |
onValueChange | ({ value, valueAsString }) => void | — |
disabled | boolean | — |
invalid | boolean | — |
otp | boolean | true |
blurOnComplete | boolean | — |
mask | boolean | — |
InputOtpSlot
Renders a single OTP input field. Use index to specify the slot position (0-based).
| Prop | Type | Default |
|---|---|---|
index | number | required |
InputOtpSeparator
Renders a visual separator between slots. Extends native <hr> props.
For a complete list of props, see the Ark UI documentation.