Skip to Content
BBRICKSv0.7.4
PR PortalLogin

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.

prLoginCard
KeyEnglishArabic
titleWelcome backأهلًا بيك تاني
subSign in to continueسجّل دخولك عشان تكمّل
emailWork emailإيميل الشغل
passwordPasswordكلمة السر
showShow passwordاظهر كلمة السر
hideHide passwordاخفي كلمة السر
rememberKeep me signed inخليني مسجّل دخول
signInSign inادخل
signingInSigning in…بندخّلك…
emailErrEnter your work email.اكتب إيميل الشغل.
emailBadThat doesn’t look like an email address.ده مش شكل إيميل.
passwordErrEnter 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

  1. Top row (with brandMark or languageToggle): mark at the start, language switch at the end, 28px below.
  2. Form (noValidate, aria-busy while 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 forgotPassword slot.
    • Button: full width, 48px, ink, "Sign in" / "Signing in…".
    • Footnote (optional): 12px centred muted.
  3. OTP step (step="otp" and otp): an OtpStep replaces the form.

Variants

PropValueEffect
stepcredentials (default)Email and password
otpThe one-time code step (needs otp)
defaultRemembertrue (default) / false"Keep me signed in" starts ticked or not

States

StateTrigger
Default—
Missing fieldsubmit with an empty email or password: "Enter your work email." / "Enter your password.", fields aria-invalid
Bad emailnot name@domain.tld: "That doesn't look like an email address."
Password showneye pressed: type="text", aria-pressed, label "Hide password"
Pendingpending: button "Signing in…" and disabled, form aria-busy
Sign-in failederror: alert banner above the fields
Code stepstep="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 error without 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 LoginLayout without 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, correct autocomplete values and type="email"; errors tied by aria-describedby, fields aria-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.

See also: Button · useLanguage · PrIcon

Source

src/pr/login/LoginCard.tsx (line 74) on GitHub.

On this page