All components
Chewypixel component

Code Input

One box per digit for verification codes, with a blinking caret in the next box. Pasting a code and autofill from SMS both work.

Enter the 6-digit code we emailed you.

Installation

npx shadcn@latest add @chewypixel/code-input

Usage

"use client";

import { useState } from "react";
import { CodeInput } from "@/components/ui/code-input";

export function VerifyEmail() {
  const [code, setCode] = useState("");

  return <CodeInput value={code} onChange={setCode} onComplete={(code) => console.log(code)} aria-label="Code" />;
}

Props

value

The digits typed so far.

string

onChange

Called with the digits on every change.

(value: string) => void

onComplete

Called once every box is filled.

(value: string) => void

length

How many digits the code has.

number = 6

Released under the MIT License.

More components

See them in a real app

These components come from Mochi, our admin dashboard template built with Next.js, shadcn/ui and Motion.