Components
- Accordion
- Action BarUpdated
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- BadgeUpdated
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- CalendarUpdated
- CardUpdated
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context MenuUpdated
- Data List
- Date Picker
- DialogUpdated
- DrawerUpdated
- Editable
- FieldUpdated
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- MarqueeUpdated
- Menu
- Native Select
- Number InputUpdated
- 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
- TableUpdated
- Tabs
- Textarea
- TimerUpdated
- ToastUpdated
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Hooks
Installation#
pnpm dlx shadcn@latest add @shark/input-otp
Anatomy#
InputOTP ├── InputOTPSlot └── InputOTPSeparator
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
❌
States#
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 *:data-[slot=input-otp-input]:size-* and *:data-[slot=input-otp-input]:text-* 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 is the first slot.
| Prop | Type | Default |
|---|---|---|
index | number | required |
InputOTPSeparator#
Visual separator between slots.
For a complete list of props, see the Ark UI documentation.