Code Input
A one-time code, one 48 px box per character, over one real input so paste and the phone's code autofill work. Built on ui-sdk's OTP Input. Used for phone verification in onboarding.
BetaReady to use. Its API can still change in a minor release; the changelog says when.
import { CodeInput } from "@leap-crm/design-system";Playground
Change a prop and the component follows. Its code is under Props.
Props
length
isInvalid
disabled
Best practices
When to use it, and the rules that apply in particular places.
| Guidance | Practice |
|---|---|
| Do | Use it for a one-time code with a fixed length, like the SMS code that verifies a lawyer's phone in onboarding. |
| Do | Put it in a Field with a label. The field's error turns the boxes red and is announced, so the state isn't shown by colour alone. |
| Do | Verify in onComplete, which runs once every box is filled, typed or pasted, so nobody has to press a button after pasting the code. |
| Do | Write the error as what to do next, like "Please enter the code we sent you", and clear it in onChange when they start again. |
| Don't | Use it for a matter number, a reference or any value without a fixed length. Use Input. |
| Don't | Build the boxes from separate inputs. It sits over one real input so paste and the phone's code autofill work. |
Props
Also takes ui-sdk's OTP Input options: value, defaultValue, pattern (digits by default), inputMode, autoComplete, name, disabled, id and autoFocus.
| Prop | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | How many characters the code has, one box each. |
| onChange | (value: string) => void | — | Runs on every change with the code so far. |
| onComplete | (value: string) => void | — | Runs once every box is filled, typed or pasted, like to verify it. |
| isInvalid | boolean | — | Draws every box red, and the active one with the red ring. Inside a Field, its error does this. |
| className | string | — | Classes added to the root element, merged with its own. Tokens only. |
Code
What the playground shows, ready to copy.
import { CodeInput } from "@leap-crm/design-system";
<CodeInput aria-label="Verification code" />Keyboard
The keys it answers to. Tab moves between components, arrows move within them.
| Keys | What they do |
|---|---|
| Typing | Fills the slots in order. |
| Backspace | Deletes the last character. |
| ArrowLeft | Goes back a slot; typing then replaces its character. |



