OTP Field.
One code, a sequence of focused slots.
Root owns length, validation, paste and value. Label the overall code and later digit inputs. Use a unique ID per instance and allow native autofill/paste; do not announce every keystroke as an error.
Make it yours
Preparing the example…
Composition
AnatomyRoot owns length, validation, paste and value. Label the overall code and later digit inputs. Use a unique ID per instance and allow native autofill/paste; do not announce every keystroke as an error.
label htmlFor=inputId
OTPField.Root id=inputId (length, value)
├── OTPField.Input
├── OTPField.Input
└── … remaining inputs / OTPField.SeparatorA place to start
UsageImport the stylesheet once at your application root. This complete example reflects the properties selected above.
Loading example…
Details that make a difference
Examples & statesSizes
Compare the three Dixy shirt sizes side by side.
Loading source…
Visual treatments
Emphasis changes presentation while the primitive keeps behavior.
Loading source…
Corner radii
Contextual rounding applies to the control or surface; large panels stay readable.
Loading source…
Materials
Optional static finishes use the same public component. Import materials.css in your application.
Loading source…
The finer details
API referenceGenerated from Dixy’s local TypeScript interfaces. Native and Base UI OTPField props are forwarded; this table covers the options Dixy adds.
OTPFieldRoot
| Prop | Type / description | Default |
|---|---|---|
size | "sm" | "md" | "lg"Digit slot dimensions. | md |
variant | "soft" | "outline"Visual emphasis; behavioral state remains primitive-owned. | outline |
radius | "none" | "sm" | "md" | "lg" | "full"Contextual rounding; panels cap full rounding to preserve content. | Theme.radius |
material | "matte" | "glossy" | "soft" | "metal" | "paper"Optional static finish; import materials.css. | Theme.material |
Built from the same foundations
Styling tokensChange Theme settings above to compare appearance, accent, neutral, radius, spacing density, motion and direction. Override component aliases on a Theme root so custom properties follow portaled content too. The wrapper merges className, style, refs and render composition with its owning primitive.
| Token | Purpose |
|---|---|
--dixy-primitive-gap | The component-specific starting point. |
--dixy-font-label-md | Control label font and line height; body roles remain readable in text inputs. |
--dixy-color-background-selected | Selected surfaces use semantic color across appearances. |
--dixy-color-border-focus | Focus indication remains visible independently of shadows. |
--dixy-spacing-inset-sm | Density-aware component padding. |
--dixy-motion-transition-feedback | Short state feedback, reduced by the inherited motion setting. |
Consider everyone
AccessibilityBase UI coordinates paste, autofill and focus. Keep slot labels meaningful and never log real verification codes. Provide meaningful names and verify the complete interaction with a keyboard. Color alone must not communicate state.
Target: WCAG 2.2 AA. Automated tests cover selected behavior; manual screen-reader, contrast, and zoom validation remain part of the release checklist.
Build it. Then understand it.
Base UI coordinates paste, autofill and focus. Keep slot labels meaningful and never log real verification codes. Component aliases reference Dixy semantic tokens; refs, events and render composition are forwarded unchanged. Visual settings follow Dixy shirt sizes, contextual radii and semantic tokens where applicable. Static finishes are optional, and reduced motion is immediate. Base UI keeps refs, state, events, keyboard and presence; this implementation pass does not establish WCAG conformance.
--dixy-primitive-gap