ReasonDialog
The PR mock's reason modals (reasonModal, pauseProgram, changeTier): a reason that is required before the confirm button does anything, and an optional note the other side sees. On the kit Modal (focus trap, Escape, scrim). Confirm stays enabled; pressing it without a reason marks the field invalid and says why.
import { ReasonDialog } from '@ergasti/bricks';Examples
Ask why
A modal with a reason to pick (or free text) and an optional note; confirmLabel names the action. Use mode="text" for a free-text reason.
Code
import { useState } from 'react';
import { Button, ReasonDialog } from '@ergasti/bricks';
function Reject() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState('');
return (
<>
<Button onClick={() => setOpen(true)}>Reject Sara Ali</Button> <small>{last}</small>
<ReasonDialog
open={open} onClose={() => setOpen(false)} onConfirm={(result) => { setLast(`Rejected: ${result.reason}`); setOpen(false); }}
title="Reject Sara Ali?" sub="They won’t join Glow Lab. They can request again after 2 weeks (29 Nov 2026)."
reasons={['Not a fit for this brand', 'Audience doesn’t match', 'Already promoting a competitor', 'Other'].map((r) => ({ value: r, label: r }))} confirmLabel="Reject"
/>
</>
);
}Free text, saving, failed
mode="text" asks for a required written reason (pausing a program); tone="ink" is the neutral look. While the app saves, busy locks the dialog; a failed save comes back as error, shown above the buttons. Confirm to see both.
Code
import { useState } from 'react';
import { Button, ReasonDialog } from '@ergasti/bricks';
function TextBusyError() {
const [open, setOpen] = useState(false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
return (
<>
<Button onClick={() => { setError(null); setOpen(true); }}>Pause Glow Lab</Button>
<ReasonDialog
open={open} onClose={() => setOpen(false)}
onConfirm={() => { setBusy(true); setError(null); window.setTimeout(() => { setBusy(false); setError('Could not pause: the program has a payout in progress.'); }, 1200); }}
title="Pause Glow Lab?" sub="Coupons stop working until you resume the program."
mode="text" tone="ink" confirmLabel="Pause program" busy={busy} error={error}
/>
</>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prReasonDialog, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
reason | Reason | السبب |
choose | Choose a reason | اختار سبب |
note | Note | ملاحظة |
noteHint | (optional, they’ll see it) | (اختياري، هيشوفها) |
cancel | Cancel | إلغاء |
required | Required | لازم |
reasonErr | Choose a reason. | اختار سبب. |
textErr | Write a reason. | اكتب السبب. |
other | Other | سبب تاني |
Design guidance
How the BRICKS design system uses ReasonDialog. Written in docs/content/components/ReasonDialog.md; the props above are read from the code, which wins where the two disagree.
A modal that asks for a required reason before a PR decision runs (reject, pause, decline, move); use it whenever the other side must be told why.
ReasonDialog is the PR mock's reasonModal / pauseProgram / changeTier. In select mode PR picks one reason from a list and may add a note the creator or brand will see; in text mode PR types a required free-text reason. Confirm stays enabled: pressing it without a reason marks the field invalid and says why, so the rule is learned, not hidden. It sits on the kit Modal (focus trap, Escape, scrim) and resets each time it opens.
Anatomy
- Modal: the kit
Modal(role="dialog",aria-modal), title, close ×, scrim; 20px title under theprtheme. - Hint (
sub): what happens next, under the title ("They can request again after 2 weeks (29 Nov 2026)."). - Reason field:
selectmode: a 42px<select>"Choose a reason" with thereasons;textmode: an<input>with placeholder "Required". - Note field (
selectonly): "Note (optional, they'll see it)", a 3-row textarea, min 84px, resizable. - Footer: an error alert (with
error) pushed to the start, "Cancel", and the confirm button intone.
Variants
| Prop | Value | Look | When to use |
|---|---|---|---|
mode | select (default) | Reason list + optional note | Rejections with a fixed set of reasons (join requests, brand requests) |
text | One required text input | Pause a program, move a tier, any decision without a fixed list | |
tone | rasp (default) | Raspberry confirm button | Rejections, pauses, declines |
ink | Ink confirm button | A neutral save that still needs a reason |
States
| State | Trigger |
|---|---|
| Closed | open={false} |
| Open, fresh | open becomes true: reason, note and the "tried" flag reset |
| Invalid | Confirm pressed with an empty (or blank) reason: field shows "Choose a reason." / "Write a reason.", onConfirm not called |
| Busy | busy: confirm disabled while the request runs |
| Error | error: role="alert" line in the footer ("We couldn't reject this request. Try again.") |
| Focus | select, input and textarea get a raspberry border and --focus-ring |
Types
Words: provider labels.prReasonDialog (reason, choose, note, noteHint, cancel, required, reasonErr, textErr, other).
ReasonResult (onConfirm): { reason, note }, both trimmed.
Usage
import { ReasonDialog } from '@ergasti/bricks';
<ReasonDialog
open={rejecting != null}
onClose={() => setRejecting(null)}
onConfirm={({ reason, note }) => reject(rejecting!.id, reason, note)}
title="Reject Sara Ali?"
sub="They won't join Glow Lab. They can request again after 2 weeks (29 Nov 2026)."
reasons={[
{ value: 'fit', label: 'Not a fit for this brand' },
{ value: 'audience', label: "Audience doesn't match" },
{ value: 'competitor', label: 'Already promoting a competitor' },
{ value: 'other', label: 'Other' },
]}
confirmLabel="Reject"
busy={saving}
error={saveError}
/>// Campaign page › Status: pausing needs a typed reason
<Button variant="rasp" onClick={() => setPausing(true)}>Pause program</Button>
<ReasonDialog
open={pausing}
onClose={() => setPausing(false)}
onConfirm={({ reason }) => pauseProgram('glow-lab', reason)}
title="Pause Glow Lab's program?"
sub="Every creator code stops earning straight away."
mode="text"
confirmLabel="Pause program"
/>// Approvals: the bulk bar's Reject opens it for all selected rows
<PrBulkBar count={sel.size} onClear={clear}>
<BulkAction kind="danger" onClick={() => setRejecting([...sel])}>Reject</BulkAction>
<BulkAction kind="approve" onClick={approveAll}>{`Approve ${sel.size}`}</BulkAction>
</PrBulkBar>Free text, saving, failed. mode="text" asks for a required written reason (pausing a program); tone="ink" is the neutral look. While the app saves, busy locks the dialog; a failed save comes back as error, shown above the buttons. Confirm to see both. (docs example TextBusyError)
import { useState } from 'react';
import { Button, ReasonDialog } from '@ergasti/bricks';
export function TextBusyError() {
const [open, setOpen] = useState(false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
return (
<>
<Button onClick={() => { setError(null); setOpen(true); }}>Pause Glow Lab</Button>
<ReasonDialog
open={open} onClose={() => setOpen(false)}
onConfirm={() => { setBusy(true); setError(null); window.setTimeout(() => { setBusy(false); setError('Could not pause: the program has a payout in progress.'); }, 1200); }}
title="Pause Glow Lab?" sub="Coupons stop working until you resume the program."
mode="text" tone="ink" confirmLabel="Pause program" busy={busy} error={error}
/>
</>
);
}Where it appears
- PR Portal › Approvals › reject a join request (row ✕ or bulk Reject),
select. - PR Portal › Affiliate programs › Campaigns › a campaign's page › Pause program,
text; Change requests › Decline. - PR Portal › Affiliate programs › Challenges › a brand request › Reject with reason.
- Library-only (no v3 mock screen): Fraud review › decision bar (inside
FraudDecisionBar). - Dashboard screens: PrApprovals, PrPrograms.
Guidelines
Do
- Put the consequence in
sub(when they can try again, what stops). - Keep reasons short and in the other side's terms; include "Other".
- Keep the dialog open on failure and pass
error; close it only on success.
Don't
- Don't disable confirm until a reason is chosen: the component explains the rule on press.
- Don't use it for tier changes:
TierChangeDialogadds "Follow the score". - Don't use
inkfor destructive decisions.
RTL and Arabic
The modal and footer mirror; the select's chevron moves to the left ([dir='rtl'] rule). Arabic words: "السبب", "اختار سبب", "ملاحظة (اختياري، هيشوفها)", "إلغاء", errors "اختار سبب." / "اكتب السبب.". Pass Arabic reasons labels yourself.
Tokens
--line, --card, --ink, --rasp, --radius-md, --focus-ring, --kit-chevron, --dlg-title-fs (Modal).
Accessibility
- Kit Modal:
role="dialog",aria-modal="true", labelled by the title; focus is trapped, Escape and the scrim close it, focus returns to the opener; the page behind becomes inert. - Fields are
FormFields: real labels,required, the error is tied to the field. - The footer error is
role="alert", announced when a save fails. - Under the
prtheme focused fields get a raspberry border plus the focus ring.
Found in the source
- Roles in the markup:
alert. - Its tests cover: “text mode: a required free-text reason (pause a program); Escape closes”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
TierChangeDialog: a tier move with "Follow the score" and a reason.Modal(kit): confirmations and forms with no reason.PrBulkBarandApprovalActions: where rejections start.
See also: Button · FormField · useLanguage · BulkAction · ChangePreview · ChoiceGroup · DecisionsCard
Source
src/pr/ReasonDialog.tsx (line 54) on GitHub.