Dokumentation (english)
Components: Shadcn UI

Input Otp

Understand the design system and contribute to it

Component preview

The live preview for UI components is handled by components/atoms/codedocs/ComponentPreview.tsx. Use it directly inside MDX whenever you want a playground-style embed. Provide componentProps to set default values and propOptions to surface toggle-able props next to the preview.

Preview
1
2
3
4
5
6

Prop reference

Auto-generated from the component source

InputOTP

  • className
  • containerClassName

React.ComponentProps<typeof OTPInput> & { containerClassName?: string; }

InputOTPGroup

  • className

React.ComponentProps<"div">

InputOTPSeparator

All props are forwarded to the underlying primitive.

React.ComponentProps<"div">

InputOTPSlot

  • index
  • className

React.ComponentProps<"div"> & { index: number; }

Code
// owner: Sona
"use client";

import * as React from "react";

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/components/ui/input-otp";
import { Button } from "@/components/ui/button";

export default function InputOTPExample() {
  const [value, setValue] = React.useState("123456");

  return (
    <div className="space-y-4">
      <InputOTP maxLength={6} value={value} onChange={setValue}>
        <InputOTPGroup>
          <InputOTPSlot index={0} />
          <InputOTPSlot index={1} />
          <InputOTPSlot index={2} />
        </InputOTPGroup>
        <InputOTPSeparator />
        <InputOTPGroup>
          <InputOTPSlot index={3} />
          <InputOTPSlot index={4} />
          <InputOTPSlot index={5} />
        </InputOTPGroup>
      </InputOTP>
      <Button variant="outline" size="sm" onClick={() => setValue("")}>
        Clear
      </Button>
    </div>
  );
}

On this page


Command Palette

Search for a command to run...

Schnellzugriffe
STRG + KSuche
STRG + DNachtmodus / Tagmodus
STRG + LSprache ändern

Software-Details
Kompiliert vor 15 Tagen
Release: v4.0.0-production
Buildnummer: master@6fbd7b5
Historie: 13 Items