Loading preview
Floating Label Input
InputsA text field whose label sits inside and floats above on focus or when filled.
One-time code entry in separate boxes with paste, autofill and keyboard navigation.
npx shadcn@latest add @venusui/otp-inputRun this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.
Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.
@/components/ui/otp-input.tsxThe code behind the preview above.
otp-input-demo.tsx
"use client"
import * as React from "react"
import { OtpInput } from "@/components/ui/otp-input"
export default function OtpInputDemo() {
const [code, setCode] = React.useState("")
return (
<div className="flex flex-col items-center gap-3">
<OtpInput value={code} onValueChange={setCode} />
<p className="text-sm text-muted-foreground" aria-live="polite">
{code.length === 6 ? `Code entered: ${code}` : "Enter the 6-digit code we sent you."}
</p>
</div>
)
}
| Prop | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | Number of characters. |
| value | string | — | Controlled value. |
| onValueChange | (value: string) => void | — | Called whenever the value changes. |
| onComplete | (value: string) => void | — | Called when every box is filled, e.g. to submit. |
| alphanumeric | boolean | false | Accept letters as well as digits. |
| label | string | "Verification code" | Accessible name for the group. |
| disabled | boolean | — | Disable all boxes. |
Only the props above.
cn helper at @/lib/utils.onComplete, but keep a submit button for people who type slowly.alphanumeric is on.autocomplete="one-time-code", so phones can fill codes from SMS.Unknown registry "@venusui"npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.No components.json foundnpx shadcn@latest init in your project first.A text field whose label sits inside and floats above on focus or when filled.
A number field with minus and plus buttons, clamped to a range.
A lock-screen passcode keypad that shakes on a wrong code and unlocks on the right one.