LoginCard
The PR mock's sign-in form (P.login's .form): title and sub line, work email, password with a show / hide toggle, "Keep me signed in" and the forgot-password link on one line, the full-width ink button, a footnote. Slots for the brand mark and the language switch; an optional one-time-code step (step="otp"). The form checks only that both fields are filled and the email is shaped like one; the app decides everything else and passes error.
import { LoginCard } 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 prLoginCard, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Welcome back | أهلًا بيك تاني |
sub | Sign in to continue | سجّل دخولك عشان تكمّل |
email | Work email | إيميل الشغل |
password | Password | كلمة السر |
show | Show password | اظهر كلمة السر |
hide | Hide password | اخفي كلمة السر |
remember | Keep me signed in | خليني مسجّل دخول |
signIn | Sign in | ادخل |
signingIn | Signing in… | بندخّلك… |
emailErr | Enter your work email. | اكتب إيميل الشغل. |
emailBad | That doesn’t look like an email address. | ده مش شكل إيميل. |
passwordErr | Enter your password. | اكتب كلمة السر. |
Design guidance
How the BRICKS design system uses LoginCard. Written in docs/content/components/LoginCard.md; the props above are read from the code, which wins where the two disagree.
The PR Portal's sign-in form: title, work email, password with show / hide, "Keep me signed in", a forgot-password slot and a full-width ink button, with an optional one-time-code step; use it inside LoginLayout.
LoginCard is the PR mock's P.login form. It checks only that both fields are filled and the email is shaped like one; the app decides everything else and passes error back ("That email and password don't match."). Slots take the brand mark, the language switch, the forgot-password link and a footnote, so routing stays in the app. With step="otp" the fields give way to an OtpStep (the mock signs in with email and password only; the code step is inferred).
Anatomy
- Top row (with
brandMarkorlanguageToggle): mark at the start, language switch at the end, 28px below. - Form (
noValidate,aria-busywhile pending):- Title:
h1, 28px / 700 display ("Welcome back"); sub line muted ("Sign in to continue"). - Error banner (with
error):role="alert", raspberry tint, alert icon. - Work email:
type="email",autocomplete="username",dir="ltr". - Password:
autocomplete="current-password",dir="ltr", with an eye toggle (a slash when shown). - Row: "Keep me signed in" checkbox (ticked by default) and the
forgotPasswordslot. - Button: full width, 48px, ink, "Sign in" / "Signing in…".
- Footnote (optional): 12px centred muted.
- Title:
- OTP step (
step="otp"andotp): anOtpStepreplaces the form.
Variants
| Prop | Value | Effect |
|---|---|---|
step | credentials (default) | Email and password |
otp | The one-time code step (needs otp) | |
defaultRemember | true (default) / false | "Keep me signed in" starts ticked or not |
States
| State | Trigger |
|---|---|
| Default | — |
| Missing field | submit with an empty email or password: "Enter your work email." / "Enter your password.", fields aria-invalid |
| Bad email | not name@domain.tld: "That doesn't look like an email address." |
| Password shown | eye pressed: type="text", aria-pressed, label "Hide password" |
| Pending | pending: button "Signing in…" and disabled, form aria-busy |
| Sign-in failed | error: alert banner above the fields |
| Code step | step="otp" |
Usage
import { LoginCard } from '@ergasti/bricks';
<LoginCard
defaultEmail="mona@trndr.co"
onSubmit={({ email, password, remember }) => signIn(email, password, remember)}
pending={signingIn}
error={failed ? "That email and password don't match." : undefined}
forgotPassword={<a className="kit-pr-link" href="/reset">Forgot password?</a>}
footnote="Brand accounts open the Brand portal. TRNDR team accounts open the PR Portal."
/>// Inside the page, with the code step after the password
<LoginLayout brand={<TrndrMark />} footer="© TRNDR 2026">
<LoginCard
onSubmit={signIn}
step={needsCode ? 'otp' : 'credentials'}
otp={{ destination: '+20 10•• ••• 471', onSubmit: verify, onResend: resend, onBack: () => setNeedsCode(false), pending: verifying, error: codeError }}
languageToggle={<Button size="sm" variant="ghost" onClick={toggleLang}>عربي</Button>}
/>
</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. (docs example TwoStep)
import { useState } from 'react';
import { Button, LoginCard, LoginLayout, OtpStep } from '@ergasti/bricks';
export 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>
);
}Where it appears
- PR Portal › Login (
P.login) › the form side. - Dashboard screen: PrLogin.
Guidelines
Do
- Say what failed in
errorwithout revealing which field was wrong. - Put the forgot-password link in the slot so it sits on the remember row.
- Keep the footnote to who lands where after signing in.
Don't
- Don't validate passwords client-side beyond "filled".
- Don't use it outside
LoginLayoutwithout giving it a 380px column. - Don't clear the email after a failed sign-in.
RTL and Arabic
The card mirrors; email and password inputs stay dir="ltr". Arabic words: "أهلًا بيك تاني", "سجّل دخولك عشان تكمّل", "إيميل الشغل", "كلمة السر", "خليني مسجّل دخول", "ادخل" / "بندخّلك…".
Tokens
--ink, --ink-3, --line, --card, --rasp, --rasp-50, --rasp-ink, --bad, --radius-md, --radius-sm, --focus-ring, --focus-ring-field, --font-family-display.
Accessibility
- A real
<form>with labelled fields, correctautocompletevalues andtype="email"; errors tied byaria-describedby, fieldsaria-invalid. - The error banner is
role="alert". - The eye button is labelled "Show password" / "Hide password" with
aria-pressed; on touch its hit area grows to 44px. - The title is the page's
h1.
Found in the source
- Roles in the markup:
alert. - ARIA attributes set:
aria-busy,aria-invalid,aria-describedby,aria-pressed,aria-label,aria-hidden. - Its tests cover: “takes label overrides”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
LoginLayout: the page around it.OtpStep: the code step.
See also: Button · useLanguage · PrIcon
Source
src/pr/login/LoginCard.tsx (line 74) on GitHub.