Skip to Content
BBRICKSv0.7.4
KitPrimitives

Button

A real <button>, type="button" unless told otherwise, so it never submits a form by accident.

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

Examples

Variants

The looks of the mock's .btn family: default, ink, rasp, ghost and white. lime and on-dark have their own example below.

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

function Variants() {
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>
      <Button>Default</Button>
      <Button variant="ink">Ink</Button>
      <Button variant="rasp">Rasp</Button>
      <Button variant="ghost">Ghost</Button>
      <Button variant="white">White</Button>
    </div>
  );
}

Sizes and disabled

size="sm" is the compact button used in toolbars.

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

function SizesAndDisabled() {
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, alignItems: 'center' }}>
      <Button size="sm">Small</Button>
      <Button>Medium</Button>
      <Button disabled>Disabled</Button>
    </div>
  );
}

Lime and on dark

variant="lime" is the sidebar's "Contact TRNDR" button, lime on the ink sidebar. variant="on-dark" is the outline button on the raspberry hero; it replaces className="kit-btn--on-dark", which still works.

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

function OnDark() {
  return (
    <div style={{ display: 'grid', gap: 16 }}>
      <div style={{ background: 'var(--ink)', borderRadius: 18, padding: 20, display: 'flex', flexWrap: 'wrap', gap: 12 }}>
        <Button variant="lime">Contact TRNDR</Button>
        <Button variant="lime" size="sm">Small</Button>
      </div>
      <div style={{ background: 'var(--rasp)', borderRadius: 18, padding: 20, display: 'flex', flexWrap: 'wrap', gap: 12 }}>
        <Button variant="white">Top up</Button>
        <Button variant="on-dark">Pay by bank transfer</Button>
      </div>
    </div>
  );
}

Danger and OK

variant="danger" (red words on a pale raspberry line) for "Remove creator" or "Reject"; variant="ok" (solid green) for "Approve".

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

function DangerAndOk() {
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>
      <Button variant="danger">Remove creator</Button>
      <Button variant="ok">Approve</Button>
      <Button variant="danger" size="sm">Reject</Button>
      <Button variant="ok" size="sm">Approve</Button>
    </div>
  );
}

Props

Prop

Type

Also accepts the react and dom attributes of the element it renders; they are passed through.

Design guidance

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

A pill-shaped action button in nine looks; use it for every in-page action (save, approve, export, open a dialog).

Button is the mock's .btn family: a real <button> that defaults to type="button", so it never submits a form by accident. Every looks is a variant on one base (14px 600 text, pill radius, --control-h minimum height, 1px line); variants change only colour. It passes every native button attribute through, so disabled, aria-*, form and onClick work as usual.

Anatomy

  1. Container (button.kit-btn): inline-flex, 6px gap, padding 9px 16px, radius 99px, no wrap.
  2. Label: the children (text, an Icon, an arrow).
  3. Icon (optional child svg): 15px, stroke currentColor.

Variants

The products differ (the brand book's "Choosing a button"): the Brand dashboard submits forms and dialogs in rasp; the PR Portal commits in ink and keeps rasp for creating and for confirming something destructive. Labels are the v3 mocks' own.

variantLookBrand dashboardPR Portal
'rasp'Solid raspberry, white text; hover --rasp-dThe forward action of a page, card or dialog, every dialog submit: "Find creators", "+ Request a challenge", "Send request", "Save gift list", "Create group", "Send to TRNDR"Creating and sending ("+ New", "Launch challenge", "Send"); the confirm of a destructive dialog ("Reject", "Pause program")
'ink'Solid ink, white textUtility actions on a value: "Copy link", "Download PDF", "Invite", "Choose gift products"Commits: "Save", "Approve", "Review", "Schedule", "Send invites"
'default'White card, --line border, ink textSecondary actions and Cancel: "See all", "Raise limit?", "Export CSV", "Edit request"Secondary actions, Cancel, and "Reject" beside an ink "Approve" in a queue row
'ghost'No border or fill, --rasp-d text; hover --rasp-50Not used in the Brand mockOpening a secondary view: "View", "Review 3 join requests", "Change fee"
'white'White fill, raspberry textOn the raspberry hero: "Top up by card"—
'on-dark'Transparent, 50 % white outline, white textOn the hero: "Where it went"—
'lime'Lime fill, olive textHelp on ink: sidebar "Contact TRNDR"The bulk bar's "Approve N" (PrBulkBar)
'danger'--rasp-100 border, --bad textA standalone destructive button outside a queue; not drawn by the v3 mockssame
'ok'Solid --ok greenA standalone approving button outside a queue; not drawn by the v3 mockssame

One raspberry button per page, card or dialog. Approve and reject in a queue are not a danger / ok pair: use ApprovalActions (Reject, then Approve in ink) in rows and drawers, and PrBulkBar for the bulk "Approve N" (lime).

sizeLookWhen
'md' (default)--control-h tall, 14pxPage and dialog actions
'sm'Padding 6px 12px, 13px; back to --control-h under 1024px for touchCard headers, table rows, toolbars

States

StateTriggerLook
HoverpointerBorder darkens (#CFD1DA); rasp, ghost, on-dark and lime have their own hover
Focus-visiblekeyboard focusThe shared kit ring: no outline, box-shadow: var(--focus-ring) (a 2px card-coloured gap, then a 2px raspberry ring)
ActivepressedMoves down 1px (not when disabled; off under reduced motion)
Disableddisabled--disabled-opacity (0.5), default cursor, removed from the tab order
Busy / soft-disabledaria-disabled="true" + className="kit-btn--off"Same faded look, stays focusable (so a reason can be read)
Long labellong textDoes not wrap (white-space: nowrap); keep labels short

Usage

A card header action:

<Card>
  <Card.Header title="Seat usage" sub="How many creators your plan lets you have"
    actions={<Button size="sm">Raise limit?</Button>} />
</Card>

A Brand dialog footer: Cancel in default, the submit in rasp:

function RequestDialog() {
  const [shown, setShown] = useState(true);
  return (
    <Modal open={shown} onClose={() => setShown(false)} title="Request a challenge"
      hint="The TRNDR team reviews it, may adjust it, and switches it on."
      footer={<>
        <Button onClick={() => setShown(false)}>Cancel</Button>
        <Button variant="rasp" onClick={() => setShown(false)}>Send request</Button>
      </>}>
      <FormField label="Challenge name"><input /></FormField>
    </Modal>
  );
}

The page's forward action, and a PR queue row's decision (ApprovalActions: "Reject" in default, "Approve" in ink):

<>
  <PageHeader title="Motivation" actions={<Button variant="rasp">+ Request a challenge</Button>} />
  <ApprovalActions onApprove={() => console.log('approve')} onReject={() => console.log('reject')}
    approveLabel="Approve Sara Ali into Glow Lab" rejectLabel="Reject Sara Ali" size="sm" />
</>

On the raspberry hero:

<div style={{ display: 'flex', gap: 12, padding: 20, borderRadius: 20, background: 'var(--rasp)' }}>
  <Button variant="white">Top up by card</Button>
  <Button variant="on-dark">Where it went</Button>
</div>

Where it appears

  • Brand › Home › hero ("Top up by card" in white, "Where it went" on the hero), Seat usage header ("Raise limit?").
  • Brand › Motivation › "+ Request a challenge" and the request dialog's "Send request" (rasp); Creators › Groups › "Create group" (rasp); Find creators › "Invite" (ink).
  • Brand › Payments › proof dialog "Download PDF" (ink); list toolbars "Export CSV" (default, sm); every dialog "Cancel" (default).
  • PR Portal › dialogs "Save" (ink) and "Cancel"; "Pause program" confirm (rasp); Approvals rows through ApprovalActions; the bulk bar "Approve N" (PrBulkBar, lime).
  • Screens: Home, Motivation, Find creators, Payments › Wallet, PR · Approvals, PR · Affiliate programs.

Guidelines

Do

  • One rasp per page, card or dialog.
  • Brand dashboard: submit dialogs and forms in rasp; use ink for utility actions on a value (copy, download, invite).
  • PR Portal: commit in ink; use rasp to create or send, and for the confirm of a destructive dialog.
  • Cancel is default, never ghost; order dialog buttons Cancel, then the action.
  • Write the action as a verb in sentence case ("Top up by card", "Export CSV"); use size="sm" in card headers, rows and toolbars.

Don't

  • Don't build approve/reject from danger + ok; use ApprovalActions and PrBulkBar.
  • Don't use Button to navigate: use ButtonLink.
  • Don't put long sentences in a button; it does not wrap.

RTL and Arabic

  • Icons and arrows in the label are yours: flip a "→" to "←" in Arabic copy.
  • Padding is symmetric; nothing else mirrors.

Tokens

--control-h, --line, --card, --ink, --rasp, --rasp-d, --rasp-50, --rasp-100, --bad, --ok, --lime, --olive, --btn-ghost-ink, --btn-ghost-hover, --btn-sm-pad, --disabled-opacity, --disabled-cursor, --focus-ring, --min-touch-target.

Accessibility

  • A native <button>: in the tab order, Enter and Space activate it, type="button" by default so it never submits a form by accident.
  • Name: its text. An icon-only button needs aria-label.
  • Focus: the shared kit ring (--focus-ring, 3:1 or more on every surface) placed last in kit.css, so no variant's own shadow hides it.
  • disabled removes it from the tab order; when the user must still reach it (to hear why it is off), use aria-disabled + kit-btn--off and describe the reason with aria-describedby.
  • Sizes: 38px tall (--control-h) on desktop; on touch screens (≤1024px) it grows to 44px tall and at least 44px wide, and sm grows to --control-h too.

Found in the source

  • Roles in the markup: link.
  • ARIA attributes set: aria-disabled.
  • Its tests cover: “has the same classes as Button for every variant and size”; “is a real link (role link) to the href, without target by default”; “Arabic + RTL: the new-tab words in Arabic; provider labels override them”; “passes other anchor props through and is reachable with Tab; Enter follows it”; “no rule dims every .kit-btn[aria-disabled]: a busy <Button aria-disabled> (TopUpAmountPicker) keeps its look”.

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

See also: Avatar · AvatarStack · CouponChip

Source

src/kit/primitives/Button.tsx (line 26) on GitHub.

On this page