Skip to Content
BBRICKSv0.7.4
KitPrimitives

CouponChip

The mock's .coupon: dashed lime chip, Jakarta 800. copyable adds a copy button and a live "Copied" (the provider's couponChip labels).

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

Examples

Copyable code

Press the chip to copy the code; it says "Copied" for a moment. Without copyable it is plain text.

Code
import { CouponChip } from '@ergasti/bricks';

function Copyable() {
  return (
    <div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
      <CouponChip code="KARI0329" copyable />
      <CouponChip code="MONA0320" />
    </div>
  );
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key couponChip, or with the component's own prop where it has one. A {name} is a value the component fills in.

couponChip
KeyEnglishArabic
copyCopy {code}انسخ {code}
doneCopiedاتنسخ
failedCouldn't copyمعرفناش ننسخ

Design guidance

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

A creator's coupon code on a dashed lime chip, optionally a button that copies it; use it wherever a code is shown in a table or a creator panel.

CouponChip is the mock's .coupon: Jakarta 800 olive text with 0.6px letter-spacing on --lime-50, a 1.5px dashed lime border and a 10px radius. Codes are always left to right. With copyable the chip becomes a button that writes the code to the clipboard and announces "Copied" (or "Couldn't copy") in a polite live region for two seconds.

Anatomy

  1. Chip (span.kit-coupon, dir="ltr"): the code.
  2. Copy button (button.kit-coupon-btn, with copyable): wraps the chip, no chrome of its own; presses down 1px.
  3. Result (span.kit-sub, aria-live="polite"): "Copied" / "Couldn't copy" for 2 s, then empty.

Variants

copyableLookWhen
false (default)Static chipTable cells (Coupons table), read-only facts
trueChip as a button + a result line beside itWhere the brand copies codes to share

States

StateTriggerLook
Default—Dashed lime chip
Focus-visibleTab to the copy buttonShared kit focus ring
PressedclickChip moves 1px down
Copiedclipboard write succeeds"Copied" / "اتنسخ" beside the chip for 2000 ms
Failedclipboard denied"Couldn't copy" / "معرفناش ننسخ" for 2000 ms

Usage

The Coupons table column:

const columns: DataColumn<Coupon>[] = [
  { key: 'code', label: 'Coupon', width: '16.1%', sortKey: 'code', sortFirst: 'asc', render: (c) => <CouponChip code={c.code} /> },
  { key: 'creator', label: 'Creator', primary: true, render: (c) => <CreatorCell id={c.creator.id} name={c.creator.name} identity={c.creator.identity} /> },
  { key: 'sales', label: 'Sales', align: 'end', render: (c) => <Money value={c.sales} /> },
  { key: 'status', label: 'Status', render: (c) => <StatusPill status={c.status} /> },
];

A copyable code in a creator panel fact:

<KeyValue items={[{ key: 'coupon', label: 'Coupon', value: <CouponChip code="LAILA15" copyable /> }]} />

Where it appears

  • Brand › Coupons › coupons table (first column).
  • Brand › Creators › creator drawer (MyCreatorPanel) › Coupon fact.
  • Screens: Coupons, Creators.

Guidelines

Do

  • Show the code exactly as the creator types it (case kept).
  • Use copyable where the next step is pasting the code somewhere.

Don't

  • Don't use it for anything that is not a coupon code (use Pill or CopyLink).
  • Don't put two copyable chips in one row; one live region each gets noisy.

RTL and Arabic

  • The code never mirrors (dir="ltr"); the result text follows the page direction.
  • Jakarta has no Arabic glyphs; codes are Latin.

Tokens

--lime-50 (fill), --olive (text), --font-family-display; the dashed border is a fixed #A8C94A.

Accessibility

  • Copy button name: "Copy LAILA15" / "انسخ LAILA15"; the result is announced through aria-live="polite".
  • Static chip is plain text.
  • dir="ltr" keeps Latin codes in order inside Arabic sentences.

Found in the source

  • ARIA attributes set: aria-label, aria-live.

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

See also: Avatar · AvatarStack · Button · ButtonLink

Source

src/kit/primitives/CouponChip.tsx (line 12) on GitHub.

On this page