Mega input
A row of boxes where each box holds one character. It is mostly used for one-time passcodes (OTP)
Overview
Use a mega input when someone has to enter a short code of a known length, like a code sent by text message or email. Each digit gets its own box, so people can see how many characters are left.

The default length is 5 boxes, and the length can be changed. The default box size is 64 × 64. On small screens the boxes shrink equally so the whole row fits.
Each box has 4 states: placeholder, filled, focus, and disabled.
Anatomy

Container: holds the row of boxes. It is as wide as the screen minus the screen padding.
Box: one square for one character. There is one box for each character in the code.
Character: the digit shown inside a filled box.
Do and Don't
Do

Use it for short codes with a fixed length, like an OTP or fixed length of pin.
Dont

Use it for long codes and the box will shrink, use regular input instead
Do

Support pasting the entire code. Let people fill all boxes at once instead of typing each digit manually.
Dont

Don't block pasting. People should be able to enter a copied code all at once.
Do

Move focus automatically as people type. Keep entry quick without requiring them to tap each box.
Dont

Pasting code only works for the first digit, leaving user frustrated
Properties
Length
The number of boxes. The default is 5. Recommended max is 6 (still proper sizing on mobile device)
When to use: set it to the exact length of the code you send.
When not to use: when the code length can change. Use the input.
States
Each box has its own state, so a single row can show filled boxes, one focused box, and empty boxes at the same time.

Placeholder
The box is empty and waiting for a character.
Filled
The box holds a character.
Focus
The box is active and is the next one to receive a character.
Disabled
The box can't be edited or focused. A disabled mega input will affect all box, it cant only affect a single digit
When to use: when the code can't be entered right now.
When not to use: when the reason isn't clear. If someone can't tell why the boxes are disabled, explain it nearby.
Layout
The container is as wide as the screen minus the screen padding (layout/screen-padding).
The boxes sit in one row. The gap between them is space/8.
Each box is a square (1:1). It is never stretched.
The largest a box can be is 64 × 64. This is the default size.
When the row doesn't fit, all boxes shrink by the same amount.
When the boxes are at their largest size, the row is centered.

Sizing
The box size depends on the container width, the gap, and the number of boxes:
size = min(64, (container width − gap × (length − 1)) ÷ length)
The example below is a mobile screen that is 375 wide, with 20 screen padding and an 8 gap. That makes the container 335 wide.

Length | Box size | Note |
|---|---|---|
4 | 64 | Largest size. The row is 280 wide and centered. |
5 | ~60.6 | |
6 | ~49.2 | |
7 | 41 | |
8 | ~34.9 |
On wider screens, boxes stay at 64 at most, and the row is centered.
Behavior
After a digit is entered, focus moves to the next box.
Backspace in an empty box moves focus back one box.
Pasting a full code fills all the boxes.
Accessibility
Each box needs an accessibility label that says which digit it is, like Digit 1 of 5.
The whole row needs a label that says what the code is for.
Focus is always visible, and moves on its own as people type, so they never have to tap each box.
Disabled boxes can't be focused.
