Skip to Content
BBRICKSv0.7.4
PR PortalGifts

UsageBar

The PR mock's "Stock used" cell (.opn with used/total, Gift analytics' By brand table): an olive bar and the muted "58/100". OpenRate is the same bar read as a percentage; this one reads as a count of a total, for any stock (gift stock, a brand's seats). The bar and the figure are drawn for the eye; assistive tech reads one sentence ("58 of 100 used").

import { UsageBar } from '@ergasti/bricks';

Examples

Shipments from brands

One line per shipment status (its pill and the count) and the open problem reports under them; the card and its heading are yours.

Pinned to TRNDR preset
Code
import { Card, GiftShipmentCounts } from '@ergasti/bricks';

function Shipments() {
  return (
    <Card>
      <Card.Header title="Shipments from brands" />
      <GiftShipmentCounts counts={{ gift_expected: 3, gift_arrived: 2, gift_confirmed: 1, gift_confirmed_diff: 1 }} problems={1} />
    </Card>
  );
}

Gift stock by brand

giftBrandColumns draws the brand, the stock used bar ("58/100", also UsageBar on its own), sent, delivered with its rate, received vs claimed and the stock pill (OK, Running low, Out of gifts).

Pinned to TRNDR preset
Code
import { DataTable, UsageBar, giftBrandColumns, type GiftBrandRow } from '@ergasti/bricks';

const rows: GiftBrandRow[] = [
  { id: 'glow', name: 'Glow Lab', color: '#C7325C', used: 58, total: 100, delivered: 38, notDelivered: 20, received: 97 },
  { id: 'mira', name: 'Mira Beauty', color: '#5B3BB0', used: 30, total: 30, delivered: 24, notDelivered: 6, received: null },
  { id: 'nile', name: 'Nile Threads', color: '#2C45A6', used: 22, total: 40, delivered: 15, notDelivered: 7, received: null },
];

function ByBrand() {
  return (
    <div style={{ display: 'grid', gap: 16 }}>
      <DataTable label="Gift stock by brand" rows={rows} rowKey={(r) => r.id} columns={giftBrandColumns('en')} onRowClick={() => {}} />
      <div style={{ width: 240 }}><UsageBar used={16} total={25} /></div>
    </div>
  );
}

The page around them

Stat tiles are KpiCard (icon, tone, sub line, progress); "Needs attention" is RowItems with a BrandCell whose title names the shipment.

Pinned to TRNDR preset
Code
import { BrandCell, KpiCard, KpiGrid, RowItems } from '@ergasti/bricks';

function Page() {
  return (
    <div style={{ display: 'grid', gap: 16 }}>
      <KpiGrid>
        <KpiCard tone="lime" icon="gift" label="Confirmed gift stock" value={195} sub="69 units left to pick" progress={65} />
        <KpiCard tone="lilac" icon="check" label="Delivered" value={89} sub="71% delivery rate · 37 not yet" progress={71} />
      </KpiGrid>
      <RowItems label="Needs attention" items={[
        { id: 'mira', lead: <BrandCell name="Mira Beauty" color="#5B3BB0" sub="Out of gifts · ask for more stock" />, onSelect: () => {} },
        { id: 'gs17', lead: <BrandCell name="Glow Lab" color="#C7325C" title="GS-0017 · Glow Lab" sub="40 units to check · Expected" />, onSelect: () => {} },
      ]} />
    </div>
  );
}

The stock rule on its own

giftStockStatus(used, total) is the mock's rule as a status key: gift_out when nothing is left, gift_low under 20% left, else gift_ok. Use it with PrStatusPill and UsageBar where you draw stock outside giftBrandColumns, so every screen agrees on "Running low".

Pinned to TRNDR preset
Code
import { Card, PrStatusPill, UsageBar, giftStockStatus, type GiftBrandRow } from '@ergasti/bricks';

const rows: GiftBrandRow[] = [
  { id: 'glow', name: 'Glow Lab', color: '#C7325C', used: 58, total: 100, delivered: 38, notDelivered: 20, received: 97 },
  { id: 'mira', name: 'Mira Beauty', color: '#5B3BB0', used: 30, total: 30, delivered: 24, notDelivered: 6, received: null },
  { id: 'nile', name: 'Nile Threads', color: '#2C45A6', used: 22, total: 40, delivered: 15, notDelivered: 7, received: null },
];

function StockRule() {
  const rows = [['Glow serum set', 58, 100], ['Kemet candle', 86, 100], ['Nile tote', 40, 40]] as const;
  return (
    <Card>
      <ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 12 }}>
        {rows.map(([name, used, total]) => (
          <li key={name} style={{ display: 'grid', gridTemplateColumns: '1fr 140px auto', gap: 16, alignItems: 'center' }}>
            <b>{name}</b>
            <UsageBar used={used} total={total} />
            <PrStatusPill status={giftStockStatus(used, total)} />
          </li>
        ))}
      </ul>
    </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 prUsageBar, or with the component's own prop where it has one. A {name} is a value the component fills in.

prUsageBar
KeyEnglishArabic
of{used} of {total} usedاتصرف {used} من {total}

Design guidance

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

A small olive bar with a muted "58/100" that shows how much of a stock is used; use it in table cells for gift stock, seats or any used-of-total count.

UsageBar is the PR mock's "Stock used" cell in Gift analytics' By brand table. It reads as a count of a total, where OpenRate (same bar) reads as a percentage. The bar and the figure are drawn for the eye; assistive tech reads one sentence ("58 of 100 used"). The percentage is rounded down, so a full bar always means every unit is used.

Anatomy

  1. Wrapper: <span class="kit-pr-opn kit-pr-usage">, a flex row, 8px gap, at least 150px wide (no minimum under 600px).
  2. Track: 6px, --track background, radius 99px; the fill is olive to usagePercent(used, total)%. aria-hidden.
  3. Figure: "58/100", 12px --ink-3, dir="ltr", no wrap, aria-hidden.
  4. Read-out: visually hidden "58 of 100 used" (or label).

Variants

No visual variants. The fill reflects the data.

States

StateTriggerLook
Part used0 < used < totalPartial bar, floor of the percentage
Fullused >= total (total > 0)Full bar
Empty stocktotal <= 0Empty bar, "0/0"
Nothing usedused <= 0Empty bar

Types

Also exported: usagePercent(used, total) (0-100, rounded down).

Usage

import { UsageBar } from '@ergasti/bricks';

<UsageBar used={58} total={100} />
// Gift analytics › By brand: giftBrandColumns puts a UsageBar in "Stock used"
<Card title="By brand" sub="Click a brand to see its gift stock">
  <DataTable label="Gift stock by brand" rows={brands} rowKey={(b) => b.id}
    columns={giftBrandColumns('en')} onRowClick={(b) => openGiftStock(b.id)} chevron={false} />
</Card>
// A custom read-out for a different stock
<UsageBar used={12} total={15} label="12 of 15 seats taken" />

The stock rule on its own. giftStockStatus(used, total) is the mock's rule as a status key: gift_out when nothing is left, gift_low under 20% left, else gift_ok. Use it with PrStatusPill and UsageBar where you draw stock outside giftBrandColumns, so every screen agrees on "Running low". (docs example StockRule)

import { BrandCell, Card, DataTable, GiftShipmentCounts, KpiCard, KpiGrid, PrStatusPill, RowItems, UsageBar, giftBrandColumns, giftStockStatus, type GiftBrandRow } from '@ergasti/bricks';

const rows: GiftBrandRow[] = [
  { id: 'glow', name: 'Glow Lab', color: '#C7325C', used: 58, total: 100, delivered: 38, notDelivered: 20, received: 97 },
  { id: 'mira', name: 'Mira Beauty', color: '#5B3BB0', used: 30, total: 30, delivered: 24, notDelivered: 6, received: null },
  { id: 'nile', name: 'Nile Threads', color: '#2C45A6', used: 22, total: 40, delivered: 15, notDelivered: 7, received: null },
];

export function StockRule() {
  const rows = [['Glow serum set', 58, 100], ['Kemet candle', 86, 100], ['Nile tote', 40, 40]] as const;
  return (
    <Card>
      <ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 12 }}>
        {rows.map(([name, used, total]) => (
          <li key={name} style={{ display: 'grid', gridTemplateColumns: '1fr 140px auto', gap: 16, alignItems: 'center' }}>
            <b>{name}</b>
            <UsageBar used={used} total={total} />
            <PrStatusPill status={giftStockStatus(used, total)} />
          </li>
        ))}
      </ul>
    </Card>
  );
}

Where it appears

  • PR Portal › Gift analytics › "By brand" table, Stock used column.
  • Dashboard screen: PrGiftAnalytics.

Guidelines

Do

  • Use it for counts of a total; use OpenRate for rates.
  • Give a specific label when "used" is vague for the stock.
  • Pair it with a status pill (giftStockStatus: OK / Running low / Out of gifts) when the level matters.

Don't

  • Don't colour the bar by level; the status pill says it.
  • Don't use it for money progress: use the kit's progress patterns with amounts.

RTL and Arabic

The track fills from the inline start (right in Arabic). The figure stays dir="ltr" ("58/100"). Arabic read-out: "اتصرف 58 من 100".

Tokens

--track, --olive, --ink-3.

Accessibility

The bar and "58/100" are aria-hidden; a visually hidden sentence carries the value, so screen readers hear "58 of 100 used" once.

Found in the source

  • ARIA attributes set: aria-hidden.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

  • OpenRate: the same bar as a percentage (messages opened).
  • GiftShipmentCounts: the Shipments card on the same page.
  • ShareBar (kit): a value of a max with its own label, on brand-dashboard surfaces.

See also: useLanguage · Card · DataTable · KpiGrid · KpiCard · RowItems · BrandCell · PrStatusPill · BrandGiftStockCard · GiftAttentionList · GiftClaimCheck · GiftShipmentCard

Source

src/pr/ganalytics/UsageBar.tsx (line 42) on GitHub.

On this page