Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Input OTP

    A one-time code, typed one character per slot. Typing moves to the next slot, Backspace goes back, and pasting a whole code fills every slot. The active slot shows the focus outline and a caret.

    Install

    npx shadcn@latest add @nelumbo/input-otp

    Six digits

    Two groups of three with a dash between them. Click the first slot or the label, then type or paste the code. The value is controlled: the line below shows it as it changes.

    We sent a 6-digit code to your phone.

    Value: empty (0/6)

    Verdicts

    The code checks itself when the last character lands. status="success" washes the slots green in a wave; status="error" (or aria-invalid) shakes the code and turns it red, with the error text tied to the input by aria-describedby. Try 123456, then anything else. This one is a connected group: the slots share one bar.

    Four-digit PIN

    Any length works: set maxLength and give each slot an index. Two groups of two keep a PIN readable.

    Letters and digits

    REGEXP_ONLY_DIGITS_AND_CHARS accepts letters and digits, useful for recovery codes. Input is kept to that pattern; pasted text that does not match is dropped.

    Disabled

    The whole code is inert and dimmed. Focus skips it.

    4
    8

    Props

    PropTypeDefaultNotes
    maxLengthnumberNumber of slots. Required
    value / onChangestring / (value) => voidControlled; onChange gets the whole code
    patternRegExp stringUse REGEXP_ONLY_DIGITS, REGEXP_ONLY_CHARS or REGEXP_ONLY_DIGITS_AND_CHARS
    onComplete() => voidCalled once every slot is filled
    status"success" | "error"Verdict on a complete code: a green wave, or a shake in red
    aria-invalidbooleanfalseSame as status="error"; pair with aria-describedby
    disabledbooleanfalseDims the code and removes it from the tab order
    autoCompletestringUse "one-time-code" so phones offer the SMS code
    aria-label / label forstringName the hidden input. A visible label with htmlFor works too
    InputOTPGroup connectedbooleanfalseSlots sit on one bar with small inner corners
    InputOTPSlot indexnumberPosition in the code, starting at 0
    InputOTPSeparatorA short dash between groups; not announced as content