Skip to Content
BBRICKSv0.7.4
PR PortalSettings and permissions

SettingRow

One setting line (the mock's gift rules .rule): a bold title and a muted description, its value area under them (a number with a unit and "Reset to 90"), and the control at the end, usually a Switch. off dims the value area (the cooldown days while the cooldown is off) and makes it inert. The control is labelled by the title.

import { SettingRow } 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".

Pinned to Arabic
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

Design guidance

How the BRICKS design system uses SettingRow. Written in docs/content/components/SettingRow.md; the props above are read from the code, which wins where the two disagree.

One setting line: a bold title over a muted description, an optional value area under them, and the control (usually a Switch) at the end; use it to build PR gift rules and platform settings cards.

SettingRow is the PR mock's gift rules .rule. Rows stack inside a card, ruled between (the first has no top rule). off dims the value area and makes it inert while its switch is off (the cooldown days while the cooldown is off). The control can be a function that receives the title's and description's ids, so a control without its own label is labelled by the row. density="tight" is the mock's denser gift rules list. NumberSetting and PlatformDefaultRow are built for its value area.

Anatomy

  1. Row: <div class="kit-pr-rule">, flex, title block and control space-between, 14px block padding, top --line rule (none with first, which also trims the top padding to 4px).
  2. Title: <b id>.
  3. Description: muted, 13px (12px tight), 2px under the title (0 tight).
  4. Value area (children): 8px below; at 40% opacity and inert with off.
  5. Control: at the end, never shrinks.

Variants

PropValueLookWhen to use
densitydefault13px description, 2px gapShort settings cards, platform defaults
tight12px description, no gap, 12px unitsLong rule lists (Brand detail gift rules)
firsttrueNo top rule, 4px top paddingFirst row in a card
offtrueValue area dimmed and inertThe row's switch is off

States

Default; off (dimmed, inert, aria-disabled); focus and hover belong to the control.

Usage

import { useState } from 'react';
import { Card, NumberSetting, SettingRow, Switch } from '@ergasti/bricks';

export 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>
  );
}
// A control labelled by the row (the function form)
<SettingRow title="One gift per challenge" description="A creator can take one gift in each challenge"
  control={({ labelId, descriptionId }) => (
    <select aria-labelledby={labelId} aria-describedby={descriptionId} value={limit} onChange={(e) => setLimit(e.target.value)}>
      <option value="1">One</option><option value="2">Two</option>
    </select>
  )} />
// Brand detail › Gift rules, tight, with Save in the card header
export function GiftRules({ save }: { save: () => void }) {
  const [pick, setPick] = useState(true);
  const [cool, setCool] = useState(true);
  const [cooldown, setCooldown] = useState('90');
  return (
<Card title="Gift rules" sub="Only PR can change these. The brand sees them read-only." actions={<Button variant="ink" size="sm" onClick={save}>Save</Button>}>
  <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={cooldown} onChange={setCooldown} unit="days" min={1} max={365} defaultValue="90" alwaysShowReset />
  </SettingRow>
</Card>
  );
}

Where it appears

  • PR Portal › Brand detail › Gift rules card (tight rows, cooldown days with "Reset to 90").
  • Library-only (no v3 mock screen): Platform settings › gift defaults (inferred), as PlatformDefaultRow.
  • Dashboard screen: PrBrandDetail.

Guidelines

Do

  • Give every switch a label (the title) or use the function form.
  • Use off rather than hiding the value, so PR sees what turns back on.

Don't

  • Don't put two controls at the end; split into two rows.
  • Don't mix densities in one card.

RTL and Arabic

The control moves to the start side (left); text aligns to the right. See the docs example in Arabic: "رجّعه لـ 90".

Tokens

--line, --ink-3 (muted), plus the control's tokens.

Accessibility

Title and description have ids for the control; off makes the value area inert and aria-disabled; the row has no interactive role of its own.

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.

See also: Button · useLanguage · Card · PermissionMatrix

Source

src/pr/Settings.tsx (line 28) on GitHub.

On this page