Skip to main content

Input otp

Separate boxes for a one-time code.

In Brand expressive

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Brand expressive: A short code sent by text or email, typed or pasted. Not for passwords or other values.

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

  • Headlines are short and bold. Three to six words.
  • Verbs that move: Join, Try, Go.
  • Playful in headlines, plain in errors.
  • Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.

The labels components use, from the voice tokens:

  • content.action.commit: Go
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Explore the drop

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

Brand expressive 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.20:1.25rem
Fill
Changes with theme
component.input-otp.backgroundcolor.text.primaryvar(--input-otp-background)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Speedcomponent.input-otp.durationmotion.duration.feedbackvar(--input-otp-duration)duration.fast:120ms
Slot
Border
Changes with theme
component.input-otp.slot.bordercolor.border.strongvar(--input-otp-slot-border)Lighttaupe.light.500:#8A6F63Darktaupe.dark.400:#B5988A
Text sizecomponent.input-otp.slot.font-sizetype.body.font-sizevar(--input-otp-slot-font-size)font.size.17:1.0625rem
Shadow
Changes with theme
component.input-otp.slot.shadowelevation.cardvar(--input-otp-slot-shadow)Lightshadow.cardDarkshadow.card-dark
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)Lightpink.light.600:#D61F7ADarkpink.dark.600:#F59ACA
Focus ring
Changes with theme
component.input-otp.slot.focus-ringcolor.border.focusvar(--input-otp-slot-focus-ring)Lightpink.light.600:#D61F7ADarkpink.dark.600:#F59ACA
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
Lighttaupe.light.200 · #F2DCCFDarktaupe.dark.100 · #33241F
Cornerradius.control
straight from the system, through --radius-md
radius.999 · 9999px