NumberSetting
A number setting's value area: the input, its unit and a "Reset to {default}" link (the cooldown days). The link shows once the value differs from defaultValue; alwaysShowReset keeps it in view at the default too, as the mock's gift rules draw it.
import { NumberSetting } from '@ergasti/bricks';Examples
Setting rows
A title, a description and a control on one row; off dims the row's detail when its switch is off, and a number setting can sit inside as children.
Code
import { useState } from 'react';
import { Card, NumberSetting, SettingRow, Switch } from '@ergasti/bricks';
function Rows() {
const [pick, setPick] = useState(true);
const [cool, setCool] = useState(true);
const [days, setDays] = useState('90');
return (
<Card>
<SettingRow first title="Creators can pick gifts" description="Show this brand’s gift list in the creator app" control={<Switch variant="ios" label="Creators can pick gifts" checked={pick} onChange={setPick} />} />
<SettingRow title="Gift cooldown" description="Days a creator waits after a gift before picking another · default 90" off={!cool} control={<Switch variant="ios" label="Gift cooldown" checked={cool} onChange={setCool} />}>
<NumberSetting label="Cooldown days" value={days} onChange={setDays} unit="days" min={1} max={365} defaultValue="90" />
</SettingRow>
</Card>
);
}Platform defaults
A default value, how many brands override it, and links to see them or edit the default.
Code
import { Card, PlatformDefaultRow } from '@ergasti/bricks';
function Defaults() {
return (
<Card>
<PlatformDefaultRow first title="TRNDR fee" description="Taken from each delivered order" value="5%" overrides={2} onShowOverrides={() => {}} onEdit={() => {}} />
<PlatformDefaultRow title="Gift cooldown" description="Days a creator waits after a gift" value="90 days" overrides={1} onShowOverrides={() => {}} onEdit={() => {}} />
<PlatformDefaultRow title="Creators can pick gifts" value="On" overrides={0} onEdit={() => {}} />
</Card>
);
}Number setting with a step and an error
step sets the arrows' step (default 1); error marks the field and says why.
Code
import { useState } from 'react';
import { Card, NumberSetting, SettingRow } from '@ergasti/bricks';
function NumberError() {
const [value, setValue] = useState('7');
const n = Number(value);
return (
<Card>
<SettingRow first title="Grace days" description="Days below zero before coupons pause" control={null}>
<NumberSetting label="Grace days" value={value} onChange={setValue} unit="days" min={5} max={30} step={5} defaultValue="7" error={n % 5 ? 'Use steps of 5 days.' : undefined} />
</SettingRow>
</Card>
);
}Reset always in view
The mock's gift rules show "Reset to 90" even at the default; alwaysShowReset does that (default false: the link appears once the value differs).
Code
import { useState } from 'react';
import { Card, NumberSetting, SettingRow } from '@ergasti/bricks';
function AlwaysReset() {
const [days, setDays] = useState('90');
return (
<Card>
<SettingRow first title="Gift cooldown" description="Days a creator waits after a gift before picking another · default 90" control={null}>
<NumberSetting label="Cooldown days" value={days} onChange={setDays} unit="days" min={1} max={365} defaultValue="90" alwaysShowReset />
</SettingRow>
</Card>
);
}Tight rows
density="tight" is the PR mock's gift rules list: the description is 12px and sits right under the title, and a NumberSetting unit is 12px, so each row is 3px shorter. Use it for a long card of rules; keep the default (13px, 2px under the title) for a short settings card or the platform defaults. Default on top, tight below.
Code
import { useState } from 'react';
import { Card, NumberSetting, SettingRow, Switch } from '@ergasti/bricks';
function Tight() {
const [pick, setPick] = useState(true);
const [cool, setCool] = useState(true);
const [days, setDays] = useState('90');
return (
<div style={{ display: 'grid', gap: 16 }}>
<Card>
<SettingRow first title="Creators can pick gifts" description="Show this brand’s gift list in the creator app" control={<Switch variant="ios" label="Creators can pick gifts (default)" checked={pick} onChange={setPick} />} />
</Card>
<Card>
<SettingRow first density="tight" title="Creators can pick gifts" description="Show this brand’s gift list in the creator app" control={<Switch variant="ios" label="Creators can pick gifts" checked={pick} onChange={setPick} />} />
<SettingRow density="tight" title="Gift cooldown" description="Days a creator waits after a gift before picking another" off={!cool} control={<Switch variant="ios" label="Gift cooldown" checked={cool} onChange={setCool} />}>
<NumberSetting label="Cooldown days" value={days} onChange={setDays} unit="days" min={1} max={365} defaultValue="90" alwaysShowReset />
</SettingRow>
</Card>
</div>
);
}Gift rules in Arabic
The tight rows as the brand page draws them in Arabic: the switch moves to the start side, the reset link reads "رجّعه لـ 90".
Code
import { useState } from 'react';
import { Card, NumberSetting, SettingRow, Switch } from '@ergasti/bricks';
function TightArabic() {
const [pick, setPick] = useState(true);
const [cool, setCool] = useState(true);
const [days, setDays] = useState('90');
return (
<Card>
<SettingRow first density="tight" title="صنّاع المحتوى يختاروا الهدايا" description="اعرض قايمة هدايا البراند في تطبيق صنّاع المحتوى" control={<Switch variant="ios" label="صنّاع المحتوى يختاروا الهدايا" checked={pick} onChange={setPick} />} />
<SettingRow density="tight" title="فترة الانتظار بين الهدايا" description="عدد الأيام اللي صانع المحتوى يستناها بعد هدية قبل ما يختار غيرها" off={!cool} control={<Switch variant="ios" label="فترة الانتظار بين الهدايا" checked={cool} onChange={setCool} />}>
<NumberSetting label="أيام الانتظار" value={days} onChange={setDays} unit="يوم" min={1} max={365} defaultValue="90" alwaysShowReset />
</SettingRow>
</Card>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prSettings, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
overridden | Overridden by {n} brand | {n} براند غيّروه لنفسهم |
noOverride | Every brand uses this default | كل البراندات ماشية بالافتراضي ده |
edit | Edit default | عدّل الافتراضي |
defaultFor | Default for every brand | الافتراضي لكل البراندات |
reset | Reset to {v} | رجّعه لـ {v} |
Design guidance
How the BRICKS design system uses NumberSetting. Written in docs/content/components/NumberSetting.md; the props above are read from the code, which wins where the two disagree.
A setting's number input with its unit and a "Reset to {default}" link; use it in a SettingRow's value area (gift cooldown days, grace days).
NumberSetting is the value area of the mock's gift rules: "[90] days · Reset to 90". The reset link appears once the value differs from defaultValue; alwaysShowReset keeps it in view at the default, as the mock draws it. Typed Arabic-Indic digits are converted to ASCII before onChange. Validation is the app's: pass error to mark the field and say why.
Anatomy
- Wrapper:
<span class="kit-pr-numset">, inline-flex, wraps, 8px gap. - Input:
type="number",inputMode="decimal", 96 × 42px,--lineborder,--radius-md; focus raspberry border + field ring; invalid red border. - Unit (optional): muted ("days").
- Reset link (with
defaultValue): raspberry "Reset to 90". - Error (optional):
role="alert"text.
Variants
| Prop | Value | Effect |
|---|---|---|
alwaysShowReset | false (default) | Reset only when value ≠ default |
true | Reset always visible (the mock) | |
step | default 1 | Arrow-key step |
States
| State | Trigger |
|---|---|
| At default | value === defaultValue: no reset (unless alwaysShowReset) |
| Changed | reset link shows |
| Invalid | error: red border, aria-invalid, alert |
| Dimmed | inside a SettingRow off: inert |
Usage
import { useState } from 'react';
import { Card, NumberSetting, SettingRow } from '@ergasti/bricks';
export function NumberError() {
const [value, setValue] = useState('7');
const n = Number(value);
return (
<Card>
<SettingRow first title="Grace days" description="Days below zero before coupons pause" control={null}>
<NumberSetting label="Grace days" value={value} onChange={setValue} unit="days" min={5} max={30} step={5} defaultValue="7" error={n % 5 ? 'Use steps of 5 days.' : undefined} />
</SettingRow>
</Card>
);
}// The mock's gift cooldown: reset always in view
export function Cooldown() {
const [cooldown, setCooldown] = useState('90');
return <NumberSetting label="Cooldown days" value={cooldown} onChange={setCooldown} unit="days" min={1} max={365} defaultValue="90" alwaysShowReset />;
}Where it appears
- PR Portal › Brand detail › Gift rules › Gift cooldown ("90 days · Reset to 90").
- Library-only (no v3 mock screen): Platform settings › gift defaults (inferred).
- Dashboard screen: PrBrandDetail.
Guidelines
Do
- Always give a
label(the input has no visible label of its own). - Validate range in the app and pass
errorin words ("From 1 to 365 days.").
Don't
- Don't use it for money; use the kit's money fields.
RTL and Arabic
Mirrors; Arabic-Indic digits typed are stored as ASCII; reset reads "رجّعه لـ 90".
Tokens
--line, --radius-md, --card, --ink, --rasp, --bad, --focus-ring, --focus-ring-field.
Accessibility
aria-label from label; error tied by aria-describedby and announced (role="alert"); the reset is a real button.
Found in the source
- Roles in the markup:
alert. - ARIA attributes set:
aria-label,aria-invalid,aria-describedby,aria-hidden. - Its tests cover: “a control can be labelled by the title (render prop)”; “tight: a 12px description and unit, no gap, the value area a flex row; label and description ids unchanged”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
SettingRow: its row.PlatformDefaultRow: a read-only default with overrides.
See also: Button · useLanguage · Card · Switch · PermissionMatrix
Source
src/pr/Settings.tsx (line 62) on GitHub.