Skip to main content

Input otp

Separate boxes for a one-time code.

Left out of Content first Forms are rare and short: newsletter and search. Actions are rare: subscribe, share, save. No step asks for a one-time code. Use instead: Input

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

  • 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​

  • Write to one person: "you", not "users".
  • Short sentences with room to breathe.
  • Explain why before asking for anything.
  • Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Browse guides

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.

Changes with theme

Content first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Input otp
Gapcomponent.input-otp.gapspace.gap.defaultvar(--input-otp-gap)space.16:1rem
Disabled opacity
when disabled
component.input-otp.disabled-opacityopacity.disabledvar(--input-otp-disabled-opacity)opacity.40:0.4
Heightcomponent.input-otp.heightsize.iconvar(--input-otp-height)size.16:1rem
Fill
Changes with theme
component.input-otp.backgroundcolor.text.primaryvar(--input-otp-background)Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8
Speedcomponent.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)Lightstone.light.500:#7A7062Darkstone.dark.400:#A39A8B
Text sizecomponent.input-otp.slot.font-sizetype.body.font-sizevar(--input-otp-slot-font-size)font.size.18:1.125rem
Shadowcomponent.input-otp.slot.shadowelevation.cardvar(--input-otp-slot-shadow)shadow.none
Border invalid
Changes with theme
when invalid
component.input-otp.slot.border-invalidcolor.status.dangervar(--input-otp-slot-border-invalid)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
Border 2
Changes with theme
component.input-otp.slot.border-2color.border.focusvar(--input-otp-slot-border-2)Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4
Focus ring
Changes with theme
component.input-otp.slot.focus-ringcolor.border.focusvar(--input-otp-slot-focus-ring)Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4
Focus ring invalid
Changes with theme
when invalid
component.input-otp.slot.focus-ring-invalidcolor.status.dangervar(--input-otp-slot-focus-ring-invalid)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightstone.light.200 · #E4DDD0Darkstone.dark.100 · #2E2A24
Cornerradius.control
straight from the system, through --radius-md
radius.8 · 0.5rem (8px)