Components
- Accordion
- Action Bar
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context Menu
- Data List
- Date Picker
- Dialog
- Drawer
- Editable
- Field
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- Table
- Tabs
- Textarea
- Timer
- Toast
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Installation
pnpm dlx shadcn@latest add https://shark.vini.one/r/input-otp.json
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>
Controlled
Use value and onValueChange to control the input.
Enter the code 1234
❌
State
Disabled
Use the disabled prop to disable the input.
Invalid
Use the invalid prop to mark the input as invalid and show error styling.
Examples
Four Digits
Use four <InputOtpSlot /> elements for a 4-digit OTP.
Separator
Add <InputOtpSeparator /> between groups of slots.
With Placeholder
Use the placeholder prop to show a placeholder in each slot.
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.
Custom Size
Pass className to <InputOtp /> to override slot dimensions and text size.
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
Single OTP slot. Use index to specify position (0-based).
| Prop | Type | Default |
|---|---|---|
index | number | required |
InputOtpSeparator
Visual separator between slots. Extends native <hr> props.
For a complete list of props, see the Ark UI documentation.