Skip to content
Mizen UI
Docs

IntroductionInstallationCLIStylingFoundationsThemingCompositionIntegrationsAccessibilityFor agents

useCopyToClipboard

AccordionAspect RatioCardCollapsibleFrameGridGroupInlineScroll AreaSectionSeparatorSpacerStack

BlockquoteCitationCodeHeadingKbdLabelLinkTextVisually Hidden

ButtonButton GroupToggleToggle groupToolbar

CalendarCheckboxCheckbox groupComboboxDate pickerDate range pickerDate-Time InputFieldFieldsetFile UploadFormInputInput groupNumber fieldOTP FieldRadio groupSelectSliderSwitchTextareaTime Input

BreadcrumbMenubarNavigation MenuPaginationSegmented ControlStepperTabs

Alert dialogCommandContext MenuDialogDrawerMenuPopoverPreview CardSheetTooltip

AlertBadgeEmptyError StateMeterProgressSkeletonSpinnerStatus dotToast

Activity FeedAvatarAvatar GroupData TableListMetricOverflow ListProperty ListTableTokenTree

Area ChartBar ListCalendar HeatmapCategory ComparisonChart FrameChart LegendChart TooltipDistributionFunnelHeatmapMetric TrendPart-to-WholeProgress RingsRadar ChartRadial BarsSankey ChartScatter ChartScore GaugeTime Series

Diagram

AttachmentCarouselCode BlockLightboxMarkdownThumbnailTimestamp

Agent ThinkingApproval CardComposerConversationInline CitationMessageMessage ScrollerQuestion CardSourcesStreaming TextSuggestionTask ListTerminalTool Call

On this page

  • Preview
  • Usage
  • Anatomy
  • Examples
  • Verify your account
  • Control sizes
  • Privacy and validation
  • Recommendations
  • Usage boundaries
  • API reference

Forms

OTP Field

Captures multi-slot one-time passwords and verification codes with keyboard and paste coordination.

idle

Usage

import { OTPField, OTPFieldInput } from "@mizen-labs/ui";

Anatomy

The parts and how they nest, taken from the preview above.

<OTPField>
	<OTPFieldInput />
</OTPField>

Examples

Verify your account

Enter the code sent to your registered device.

Control sizes

Privacy and validation

Recommendations

GuidancePractice
Do

State the code length and delivery method. Allow paste and show verification errors near the field.

Usage boundaries

GuidanceBoundary
Scope

Completing the slots does not verify the code. Expiry, rate limits, and verification belong to the server.

API reference

Public props from @mizen-labs/ui. Use exported prop types for the complete TypeScript contract.

PropTypeDefaultDescription
lengthnumber—Number of characters and slots in the one-time code.
valuestring—Controlled string value across all input slots.
defaultValuestring—Initial value for uncontrolled field presentation.
onValueChange(value: string, eventDetails: OTPFieldPrimitive.Root.ChangeEventDetails) => void—Callback fired when the entered value changes.
onValueComplete(value: string, eventDetails: OTPFieldPrimitive.Root.CompleteEventDetails) => void—Callback fired when all slots are filled.
validationType"numeric" | "alpha" | "alphanumeric" | "none""numeric"Input validation mode applied to entered characters.
maskbooleanfalseObscures entered characters for sensitive verification codes.
autoCompletestring"one-time-code"Autocomplete attribute applied to the first slot and hidden input.
disabledbooleanfalsePrevents user interaction across all slots.
readOnlybooleanfalsePresents slots in a non-editable readable state.
requiredbooleanfalseEnsures a value is provided before submitting an enclosing form.
namestring—Field name submitted with form data.
size"default" | "sm" | "lg""default"Sets control dimensions across input slots and separators.
OTPFieldOTPFieldProps"div"Root container coordinating OTP state, keyboard navigation, and slot layout.
OTPFieldInputOTPFieldInputProps"input"Individual digit slot input handling typing, backspace, and navigation.
OTPFieldSeparatorOTPFieldSeparatorProps"div"Visual divider separating groups of input slots.
OTPFieldPrimitivetypeof BaseOTPField—Low-level Base UI OTP field primitive namespace.
PreviousNumber fieldNextRadio group

Enter the six digits from your email.

Enter the 6-digit code sent to your registered device.

Compact slots for dense forms.

Standard input dimensions for general use.

Prominent slots for primary verification flows.

Obscures characters for sensitive passcode entry.

Temporarily unavailable while awaiting a new code.

Pre-filled reference code that cannot be altered.

Enter the 6-digit confirmation code.

That code is incorrect. Check it and try again.
-

Custom 123-456 composition with an explicit separator.