OTP Field

A one-time code in slots of glass. Pasting a code fills every slot.

Installation#

pnpmnpmyarnbun
$ pnpm dlx shadcn@latest add @liquikit/otp-field

Needs the @liquikit registry in your components.json. Set it up once.

Usage#

import { OtpField } from "@/components/liquikit/otp-field"
<OtpField length={6} aria-label="Verification code" />

Examples#

Grouped#

groupSize puts a gap after every few slots.

API Reference#

OtpField

PropTypeDefault
theme"light" | "dark"

Light or dark glass. Falls back to the nearest GlassThemeProvider, then light.

—
lensPartial<LensProfile>

Overrides for the lens profile, such as thickness, bevel, ior and magnification.

—
liquidnumber

How far the glass squashes and stretches as it moves. 0 keeps it rigid.

—
lengthnumber

Number of characters in the code.

6
groupSizenumber

Puts a gap after every so many slots, as in 123 456.

—
refraction"interactive" | "always"

When the glass bends the page. interactive bends it while the component is pressed, dragged or focused, always bends it all the time.

"interactive"

Also takes every prop of Base UI's otp field, plus className and style.