Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation

InputOTP

Native one-time code input with grouped visual slots and sanitized paste.

All components · Theme builder · Implementation source

Live preview

Open live input-otp preview

Install

Shell
netscript ui:add input-otp

Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

TypeScript
import { useState } from 'preact/hooks';
import { InputOTP } from '@app/components/ui/input-otp.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><InputOTP label="Verification code" /></div><p role="status">{notice}</p></>);
}

Props

Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

OwnerPropTypeOptionalDescription
InputOTPPropslabelstringNo
InputOTPPropslength4 | 6Yes
InputOTPPropsgroups1 | 2Yes
InputOTPPropsvaluestringYes
InputOTPPropsdefaultValuestringYes
InputOTPPropsonValueChange(value: string) => voidYes
InputOTPPropsstate"rest" | "focus" | "disabled" | "invalid"Yes
InputOTPPropsclassstringYes
TypeScript
InputOTPProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "class" | "size" | "value" | "defaultValue" | "maxLength" | "children">

Keyboard

KeyAction
ArrowLeft/ArrowRight/Home/EndMove the native input selection
Backspace/DeleteEdit the native code input
PasteReplace the native selection with sanitized digits

Tokens

Semantic contract roles: border/input, destructive/default, radius/input, surface/card, text/fg.

CSS custom properties referenced directly: --ns-border-width, --ns-card, --ns-control-height, --ns-destructive, --ns-fg, --ns-input-border, --ns-muted-fg, --ns-radius-input, --ns-ring, --ns-space-3, --ns-space-4, --ns-text-strong, --ns-weight-strong.

Contract and compatibility

Accessibility pattern: native one-time-code input

  • Native controls own keyboard/form behavior. Transient focus/hover is CSS/native; data-state also supports deliberate preview. Client visual/controlled updates require an island.
  • One real text input handles selection, autofill and form value; grouped slots are aria-hidden mirrors. content is slot anatomy, not a caller prop. Paste normalizes ASCII digits and preserves native selection replacement.

Design contract values marked planned are not implementation props. The props above describe what ships today.

Search all documentation

Type a term to search the documentation.