Blossom UI

OTP input

OTP input component for verification codes with auto advance, paste and autofill support, masking and validation states.

How to use it

Run npx @blossomui/react add otp-input, or copy src/components/UI/OtpInput/OtpInput.tsx into your React project and import it.

import { OtpInput } from './components/ui/OtpInput'

Props

OtpInputProps

PropTypeDescription
lengthnumberNumber of boxes.
valuestringControlled value. Use together with `onChange`.
defaultValuestringInitial value when the component is not controlled.
onChange(value: string) => voidCalled every time a character is typed, deleted or pasted.
onComplete(value: string) => voidCalled once, when every box is filled.
type'numeric' | 'alphanumeric'`numeric` accepts digits and opens the numeric keyboard on a phone, `alphanumeric` also accepts letters.
maskbooleanHide the characters, like a password.
separatorAfternumber[]Draws a dash after these boxes, for example `[3]` shows 123 - 456.
colorstringAccent color of this component: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default.
labelstring
hintstringHelper text shown under the boxes.
errorstringError message. Turns the boxes red.
successstringSuccess message. Turns the boxes green.
size'sm' | 'md' | 'lg'
disabledboolean
autoFocusbooleanFocus the first empty box when the component is shown.
namestringAdds a hidden input with this name so the code is sent with native forms.
boxLabel(position: number, length: number) => stringAccessible name of each box, for example "Character 2 of 6".

Getting started

  • Introduction
  • Installation
  • Changelog

Customization

  • Colors
  • Brand color
  • Texts and translation

Components

  • Accordion
  • Alert dialog
  • Alerts
  • Avatar
  • Badges
  • Banner
  • Breadcrumb
  • Buttons
  • Calendar
  • Cards
  • Carousel
  • Charts
  • Chip input
  • Collapsible
  • Color picker
  • Combobox
  • Command palette
  • Context menu
  • Copy button
  • Date picker
  • Drawer
  • Dropdown
  • Empty state
  • File upload
  • Footer
  • Forms
  • Hover card
  • Jumbotron
  • KBD
  • Menubar
  • Modal
  • Navbar
  • Navigation menu
  • Number input
  • OTP input
  • Pagination
  • Popover
  • Pricing
  • Progress
  • Rating
  • Resizable panels
  • Scroll area
  • Segmented control
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Spinners
  • Stats
  • Stepper
  • Survey
  • Table
  • Tabs
  • Time picker
  • Timeline
  • Timer button
  • Toasts
  • Tooltip
  • Transfer list
  • Tree