Input otp
Separate boxes for a one-time code.
In Multi-brand
See it live
npm run storybookWhen to use it
In Multi-brand: The code that verifies an email or phone.
- Use it when: A short code sent by text or email, typed or pasted.
- Not when: Passwords or any value that is not a fixed-length code.
Instead:
- Input: Any other short value.
Words
- Shared structure: object, state, next step.
- Brand tone lives in headlines and marketing copy, not in errors.
- Errors and confirmations read the same in every brand.
- Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Get started
See Voice and tone for the whole voice.
Accessibility and keyboard
Test before you ship:
- Screen readers hear one field with a label, and pasting the whole code works. undefined
Use it in code
npx open-ds add input-otp
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Input otp reads 12 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Input otp's tokens to change Input otp alone.
Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Input otp | ||
| Gap | component.input-otp.gapspace.gap.defaultvar(--input-otp-gap) | space.12:0.75rem |
| Disabled opacity when disabled | component.input-otp.disabled-opacityopacity.disabledvar(--input-otp-disabled-opacity) | opacity.40:0.4 |
| Height | component.input-otp.heightsize.iconvar(--input-otp-height) | size.16:1rem |
| Fill Changes with theme | component.input-otp.backgroundcolor.text.primaryvar(--input-otp-background) | Aster Lightslate-deep.light.900:#0F172AAster Darkslate-deep.dark.900:#F8FAFCBirch Lightslate-deep.light.900:#0F172ABirch Darkslate-deep.dark.900:#F8FAFCCoral Lightslate-deep.light.900:#0F172ACoral Darkslate-deep.dark.900:#F8FAFC |
| Speed | component.input-otp.durationmotion.duration.feedbackvar(--input-otp-duration) | duration.moderate:200ms |
| Slot | ||
| Border Changes with theme | component.input-otp.slot.bordercolor.border.strongvar(--input-otp-slot-border) | Aster Lightslate-deep.light.500:#64748BAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.500:#64748BBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.500:#64748BCoral Darkslate-deep.dark.400:#96A3B5 |
| Text size | component.input-otp.slot.font-sizetype.body.font-sizevar(--input-otp-slot-font-size) | font.size.16:1rem |
| Shadow Changes with theme | component.input-otp.slot.shadowelevation.cardvar(--input-otp-slot-shadow) | Aster Lightshadow.cardAster Darkshadow.card-darkBirch Lightshadow.cardBirch Darkshadow.card-darkCoral Lightshadow.cardCoral Darkshadow.card-dark |
| Border invalid Changes with theme when invalid | component.input-otp.slot.border-invalidcolor.status.dangervar(--input-otp-slot-border-invalid) | Aster Lightred.light.600:#C42B2BAster Darkred.dark.600:#F28B8BBirch Lightred.light.600:#C42B2BBirch Darkred.dark.600:#F28B8BCoral Lightred.light.600:#C42B2BCoral Darkred.dark.600:#F28B8B |
| Border 2 Changes with theme | component.input-otp.slot.border-2color.border.focusvar(--input-otp-slot-border-2) | Aster Lightteal.light.600:#0F766EAster Darkteal.dark.600:#7FCFC6Birch Lightpurple.light.600:#6D28D9Birch Darkpurple.dark.600:#B79DF7Coral Lightorange.light.600:#C2410CCoral Darkorange.dark.600:#F7A67F |
| Focus ring Changes with theme | component.input-otp.slot.focus-ringcolor.border.focusvar(--input-otp-slot-focus-ring) | Aster Lightteal.light.600:#0F766EAster Darkteal.dark.600:#7FCFC6Birch Lightpurple.light.600:#6D28D9Birch Darkpurple.dark.600:#B79DF7Coral Lightorange.light.600:#C2410CCoral Darkorange.dark.600:#F7A67F |
| Focus ring invalid Changes with theme when invalid | component.input-otp.slot.focus-ring-invalidcolor.status.dangervar(--input-otp-slot-focus-ring-invalid) | Aster Lightred.light.600:#C42B2BAster Darkred.dark.600:#F28B8BBirch Lightred.light.600:#C42B2BBirch Darkred.dark.600:#F28B8BCoral Lightred.light.600:#C42B2BCoral Darkred.dark.600:#F28B8B |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Aster Lightslate-deep.light.200 · #E2E8F0Aster Darkslate-deep.dark.100 · #1E293BBirch Lightslate-deep.light.200 · #E2E8F0Birch Darkslate-deep.dark.100 · #1E293BCoral Lightslate-deep.light.200 · #E2E8F0Coral Darkslate-deep.dark.100 · #1E293B |
| Corner Changes with theme | radius.control straight from the system, through --radius-md | Aster Lightradius.4 · 0.25rem (4px)Aster Darkradius.4 · 0.25rem (4px)Birch Lightradius.12 · 0.75rem (12px)Birch Darkradius.12 · 0.75rem (12px)Coral Lightradius.999 · 9999pxCoral Darkradius.999 · 9999px |