UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

8bitcn/8-bit Input-OTP

Inputs & forms
1 of 12
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

12 versions·6 librariesCompare all OTP inputs →

  • 8-bit Input-OTP
  • Input OTP
  • Input Otp
  • 8-bit Input
  • Eldora UI
  • Input
  • Input group
  • Kokonut UI
  • Input
  • Input Group
  • Ai Input
  • Ai Prompt Input

8-bit Input-OTP

A simple 8-bit input-otp component

npx shadcn@latest add https://www.8bitcn.com/r/input-otp.json
Open in v0 Docs Repo
Library
8bitcn
License
MIT
Stack
React · Tailwind CSS
Packages
cninput-otp
Also adds
input-otp
Size
117 lines

Code

components/ui/8bit/input-otp.tsx

import { type VariantProps, cva } from "class-variance-authority";

import { cn } from "@/lib/utils";

import {
  InputOTP as ShadcnInputOTP,
  InputOTPGroup as ShadcnInputOTPGroup,
  InputOTPSeparator as ShadcnInputOTPSeparator,
  InputOTPSlot as ShadcnInputOTPSlot,
} from "@/components/ui/input-otp";

import "@/components/ui/8bit/styles/retro.css";

export const inputVariants = cva("", {
  variants: {
    font: {
      normal: "",
      retro: "retro",
    },
  },
  defaultVariants: {
    font: "retro",
  },
});

interface SharedProps
  extends React.ComponentProps<"div">,
    VariantProps<typeof inputVariants> {
  className?: string;
  children?: React.ReactNode;
}

interface InputOTPProps {
  maxLength: number;
  value?: string;
  onChange?: (value: string) => unknown;
  children?: React.ReactNode;
  className?: string;
  font?: "normal" | "retro";
}

export const InputOTP = ({
  className,
  font,
  maxLength,
  value,
  onChange,
  children,
  ...otherProps
}: InputOTPProps) => {
  return (
    <div className={cn("relative w-fit", className)}>
      <ShadcnInputOTP
        maxLength={maxLength}
        value={value}
        onChange={onChange}
        {...otherProps}
        className={cn(font !== "normal" && "retro", className)}
      >
        {children}
      </ShadcnInputOTP>
    </div>
  );
};

export const InputOTPGroup = ({ className, ...props }: SharedProps) => {
  return (
    <ShadcnInputOTPGroup {...props} className={cn("flex gap-2", className)} />
  );
};

export const InputOTPSlot = ({
  className,
  font,
  index = 0,
  ...props
}: SharedProps & { index?: number }) => {
  return (
    <div className="relative size-12 border-y-6 border-foreground dark:border-ring">
      <ShadcnInputOTPSlot
        index={index}
        {...props}
        className={cn(
          "pl-1 size-full text-center text-xl tracking-widest z-0 ring-0 border-transparent ",
          font !== "normal" && "retro",
          className
        )}
      />

      <div
        className="absolute inset-0 border-x-6 -mx-1.5 border-foreground dark:border-ring pointer-events-none"
        aria-hidden="true"
      />
    </div>
  );
};

export const InputOTPSeparator = ({ className, ...props }: SharedProps) => {
  return <ShadcnInputOTPSeparator {...props} className={cn("", className)} />;
};

More like this

8-bit Scroll Area

8bitcn·Data display

Fade Content

React Bits·Cursor & effectsMIT+

8-bit Carousel

8bitcn·Media & 3D

Decrypted Text

React Bits·Text effectsMIT+

Bubble

shadcn/ui·Backgrounds

Split Text

React Bits·Text effectsMIT+

Magnetic

Motion Primitives·Cursor & effects

Text Morph

Motion Primitives·Text effects

Text Roll

Motion Primitives·Text effects

Tilt

Motion Primitives·Cards

Blur Text

React Bits·Text effectsMIT+

Text Type

React Bits·Text effectsMIT+

Text Effect

Motion Primitives·Text effects

Text Loop

Motion Primitives·Text effects

Text Scramble

Motion Primitives·Text effects