OtpStep
The login's second step (inferred: the PR mock signs in with email and password only): a one-time code in length single-digit boxes, always left to right (a code reads the same in Arabic), with the resend countdown and Back. Typing a digit moves on, Backspace on an empty box moves back, Left / Right / Home / End move between boxes, and a pasted code fills them all. The first box carries autocomplete="one-time-code" so a phone can fill it from the SMS.
import { OtpStep } from '@ergasti/bricks';Examples
Sign-in page
LoginLayout is the two-column page (brand, headline, the card); LoginCard takes email, password and "remember me", and reports a LoginValue. This frame is contained.
Code
import { Button, LoginCard, LoginLayout } from '@ergasti/bricks';
function Page() {
return (
<LoginLayout brand={<b>TRNDR.</b>} footer="© TRNDR 2026">
<LoginCard
defaultEmail="mona@trndr.co" onSubmit={() => {}}
forgotPassword={<a className="kit-pr-link" href="#">Forgot password?</a>}
languageToggle={<Button size="sm" variant="ghost">عربي</Button>}
footnote="Brand accounts open the Brand portal. TRNDR team accounts open the PR portal."
/>
</LoginLayout>
);
}Errors and the one-time code
error shows under the form; the otp step is the code screen (OtpStep): one box per digit, paste works, resend has a countdown.
Code
import { LoginCard, OtpStep } from '@ergasti/bricks';
function Otp() {
return (
<div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))' }}>
<div className="kit-card"><LoginCard onSubmit={() => {}} error="The email or password is wrong." defaultEmail="mona@trndr.co" /></div>
<div className="kit-card"><OtpStep destination="+20 10•• ••• 471" onSubmit={() => {}} onResend={() => {}} onBack={() => {}} autoSubmit={false} /></div>
</div>
);
}Inside a page that has its own main
LoginLayout draws its form side as the page's <main>. When the layout sits inside a page that already has one (a gallery, a preview, a docs frame), landmark="div" or "section" avoids a second main landmark.
Code
import { LoginCard, LoginLayout } from '@ergasti/bricks';
function Landmark() {
return (
<LoginLayout landmark="div" brand={<b>TRNDR.</b>} footer="© TRNDR 2026">
<LoginCard defaultEmail="mona@trndr.co" onSubmit={() => {}} />
</LoginLayout>
);
}Signing in, then the code step
Submit: pending turns the button into "Signing in…"; the app then moves step to otp and passes the code step's props in otp. Verifying sets the code step's own pending; a wrong code comes back as its error. brandMark, title, subtitle and defaultRemember set the card's head and the remember box.
Code
import { useState } from 'react';
import { LoginCard } from '@ergasti/bricks';
function TwoStep() {
const [step, setStep] = useState<'credentials' | 'otp'>('credentials');
const [pending, setPending] = useState(false);
const [codePending, setCodePending] = useState(false);
const [codeError, setCodeError] = useState<string | null>(null);
return (
<div className="kit-card" style={{ maxWidth: 420 }}>
<LoginCard
brandMark={<b>TRNDR.</b>} title="PR portal" subtitle="Sign in with your TRNDR team account." defaultRemember={false}
pending={pending} step={step}
onSubmit={() => { setPending(true); window.setTimeout(() => { setPending(false); setStep('otp'); }, 900); }}
otp={{
destination: '+20 10•• ••• 471', length: 4, resendAfter: 20, pending: codePending, error: codeError, autoSubmit: false,
onSubmit: () => { setCodePending(true); setCodeError(null); window.setTimeout(() => { setCodePending(false); setCodeError('That code is wrong or expired.'); }, 900); },
onResend: () => setCodeError(null), onBack: () => setStep('credentials'),
}}
/>
</div>
);
}Code step states
OtpStep alone: length digits (here 4), resendAfter seconds before Resend (here 45), pending while checking (boxes read-only, "Checking…").
Code
import { OtpStep } from '@ergasti/bricks';
function OtpPending() {
return <div className="kit-card" style={{ maxWidth: 420 }}><OtpStep destination="mona@trndr.co" length={4} resendAfter={45} pending onSubmit={() => {}} onResend={() => {}} /></div>;
}Your own headline
headline (wrap the lime words in a span) and text replace the ink side's default words.
Code
import { LoginCard, LoginLayout } from '@ergasti/bricks';
function Headline() {
return (
<LoginLayout landmark="div" brand={<b>TRNDR.</b>} headline={<>Every brand, <span>one desk</span>.</>} text="Approvals, payouts, gifts and challenges for the whole TRNDR team.">
<LoginCard onSubmit={() => {}} />
</LoginLayout>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prOtpStep, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Check your phone | شوف موبايلك |
code | Verification code | كود التأكيد |
digit | Digit {n} of {of} | الرقم {n} من {of} |
sent | [object Object] | [object Object] |
sentPlain | Enter the {n}-digit code we sent you. | اكتب الكود اللي بعتناهولك ({n} أرقام). |
verify | Verify | أكّد |
verifying | Checking… | بنتأكد… |
resend | Resend code | ابعت الكود تاني |
resendIn | Resend code in {t} | تقدر تبعته تاني بعد {t} |
back | Back | رجوع |
incomplete | Enter all {n} digits. | اكتب الـ {n} أرقام كلهم. |
Design guidance
How the BRICKS design system uses OtpStep. Written in docs/content/components/OtpStep.md; the props above are read from the code, which wins where the two disagree.
The sign-in's one-time-code step: single-digit boxes that read left to right, Verify, a resend countdown and Back; use it after the password when the account needs a code, usually through LoginCard's step="otp".
OtpStep is inferred (the PR mock signs in with email and password only). The code always reads left to right, even in Arabic. Typing a digit moves on, Backspace on an empty box moves back, arrow keys and Home / End move between boxes, and a pasted code fills the boxes from the focused one onwards; Arabic-Indic digits are accepted. The first box carries autocomplete="one-time-code" so a phone can fill it from the SMS. With autoSubmit (default) the code is sent as soon as the last box fills.
Anatomy
- Form:
<form class="kit-pr-otp" noValidate>. - Title:
h2"Check your phone" (28px display). - Line: "We sent a 6-digit code to +20 10•• ••• 471." (or "Enter the 6-digit code we sent you.").
- Boxes: a
role="group"named "Verification code",dir="ltr", a grid of 54px-tall boxes, 8px gaps; eachinputMode="numeric", named "Digit 1 of 6". - Error:
role="alert"line (the app'serror, or "Enter all 6 digits."). - Verify: full-width ink button ("Checking…" while pending).
- Foot: "Back" link at the start, "Resend code in 0:30" (muted) or the "Resend code" link at the end.
Variants
| Prop | Value | Effect |
|---|---|---|
length | 6 (default), any number | Boxes in the code |
autoSubmit | true (default) / false | Send when the last box fills, or only on Verify |
resendAfter | 30 (default) seconds | Countdown before "Resend code" |
destination | masked string | Names where the code went |
States
| State | Trigger |
|---|---|
| Typing | digits move focus forward; focus selects the box's digit |
| Pasted | a pasted code fills from the focused box |
| Incomplete | Verify with empty boxes: "Enter all 6 digits.", boxes aria-invalid |
| Pending | pending: boxes read-only, button "Checking…" and disabled |
| Wrong code | error: alert and invalid boxes |
| Countdown | onResend given and time left: "Resend code in 0:12" |
| Resend ready | countdown at 0: "Resend code" link; pressing it calls onResend, clears the boxes, restarts the countdown and focuses the first box |
Usage
import { OtpStep } from '@ergasti/bricks';
<OtpStep
destination="+20 10•• ••• 471"
onSubmit={(code) => verify(code)}
onResend={() => sendCode()}
onBack={() => setStep('credentials')}
pending={verifying}
error={wrong ? 'That code is not right. Try again.' : undefined}
/>// Through the login card (the usual way)
<LoginLayout brand={<TrndrMark />}>
<LoginCard onSubmit={signIn} step="otp" otp={{ destination: '+20 10•• ••• 471', onSubmit: verify, onResend: resend, onBack: back }} />
</LoginLayout>Code step states. OtpStep alone: length digits (here 4), resendAfter seconds before Resend (here 45), pending while checking (boxes read-only, "Checking…"). (docs example OtpPending)
import { Button, LoginCard, LoginLayout, OtpStep } from '@ergasti/bricks';
export function OtpPending() {
return <div className="kit-card" style={{ maxWidth: 420 }}><OtpStep destination="mona@trndr.co" length={4} resendAfter={45} pending onSubmit={() => {}} onResend={() => {}} /></div>;
}Where it appears
- Library-only (no v3 mock screen): a second sign-in step after PR Portal › Login (the mock signs in with email and password only).
- Dashboard screen: PrLogin.
Guidelines
Do
- Mask the destination in the app before passing it.
- Keep
autoSubmiton for SMS codes; turn it off when the user must review. - Say whether a code is wrong or expired in
error.
Don't
- Don't reverse the boxes in Arabic: codes read left to right.
- Don't shorten
resendAfterbelow what the SMS provider allows.
RTL and Arabic
The boxes stay dir="ltr"; the rest mirrors (Back on the right). Arabic words: "شوف موبايلك", "بعتنالك كود من 6 أرقام على …", "أكّد" / "بنتأكد…", "ابعت الكود تاني", "تقدر تبعته تاني بعد 0:30", "رجوع". Arabic-Indic digits typed or pasted become ASCII.
Tokens
--line, --card, --ink, --ink-3, --rasp, --bad, --radius-md, --focus-ring-field, --font-family-display.
Accessibility
- A labelled group of inputs, each "Digit n of 6"; errors tied by
aria-describedby, boxesaria-invalid. - The first box is
autocomplete="one-time-code"and auto-focused. - Full keyboard: arrows, Home / End, Backspace back; a paste fills from the focused box onwards.
- Errors are
role="alert"; Verify carriesaria-busywhile pending.
Found in the source
- Roles in the markup:
group,alert. - ARIA attributes set:
aria-labelledby,aria-describedby,aria-label,aria-invalid,aria-busy. - Keys the code handles: Backspace, ArrowLeft, ArrowRight, Home, End.
- It moves focus in code.
- Its tests cover: “Backspace on an empty box goes back and clears; arrows, Home and End move; letters are ignored”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
LoginCard: shows it withstep="otp".LoginLayout: the page.
See also: Button · useLanguage
Source
src/pr/login/OtpStep.tsx (line 65) on GitHub.