Skip to Content
BBRICKSv0.7.4
KitOverlays

Drawer

The mock's floating drawer: 400px, inset 12, radius 24, slides in from the inline end (the left in RTL). size="wide" is the same drawer at 560px, for a video player and its decision form. headerStyle, closeButton and footerDivider are the PR v3 creator drawer's looks; their defaults draw the drawer as before.

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

Examples

Side drawer

Slides in from the end edge (the left in Arabic) with the same focus handling as Modal; lead is the avatar, hint the line under the title, aside sits in the header, footer holds actions.

Code
import { useState } from 'react';
import { Avatar, Button, Drawer, KeyValue, Money } from '@ergasti/bricks';

function Details() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button variant="ink" onClick={() => setOpen(true)}>Open drawer</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Karim Hosny" hint="@karim.hosny" lead={<Avatar name="Karim Hosny" seed={1} size="lg" />} footer={<Button onClick={() => setOpen(false)}>Done</Button>}>
        <KeyValue items={[{ label: 'Orders', value: 54 }, { label: 'Sales', value: <Money value="12900.00" compact /> }]} />
      </Drawer>
    </>
  );
}

One loading state

With loading the drawer shows DialogSkeleton under its title, so the header never flickers.

Code
import { useState } from 'react';
import { Button, Drawer } from '@ergasti/bricks';

function Loading() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open a loading drawer</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Loading creator" loading size="wide"><p>Never shown while loading.</p></Drawer>
    </>
  );
}

A drawer that draws its own head

With hideTitle the title stays the dialog's accessible name but is not drawn, and the close row sits tighter on the content; use it when the body starts with its own head tile (ChallengeDetail, CreatorProfilePanel). The Modal takes the same prop.

Code
import { useState } from 'react';
import { Button, Drawer, KeyValue, Money } from '@ergasti/bricks';

function HiddenTitle() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open drawer with its own head</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Winter glow launch" hideTitle>
        <div style={{ background: 'var(--lime-50)', borderRadius: 20, padding: 20 }}>
          <b style={{ fontFamily: 'var(--font-display)', fontSize: 22 }}>Winter glow launch</b>
          <p className="kit-muted">1 Nov – 30 Nov · 64 creators</p>
        </div>
        <KeyValue items={[{ label: 'Orders', value: 312 }, { label: 'Sales', value: <Money value="184300.00" compact /> }]} />
      </Drawer>
    </>
  );
}

Header chip

aside puts a node after the title in the header, such as the creator's status.

Code
import { useState } from 'react';
import { Avatar, Button, Drawer, KeyValue, Pill } from '@ergasti/bricks';

function Aside() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open drawer with a chip</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Karim Hosny" lead={<Avatar name="Karim Hosny" seed={1} size="lg" />} aside={<Pill tone="ok">Active</Pill>}>
        <KeyValue items={[{ label: 'Orders', value: 54 }]} />
      </Drawer>
    </>
  );
}

Composed details body

The v3 drawer body for "open this row" (it replaces the deprecated DetailsDrawer): hideTitle, then a tinted DrawerHead, KeyValue figures and a RowItems list with its heading.

Code
import { useState } from 'react';
import { Button, Drawer, DrawerHead, KeyValue, Money, RowItems } from '@ergasti/bricks';

function ComposedBody() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open order</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Order #48211" hideTitle>
        <DrawerHead tone="butter" title="Order #48211" sub="13 Nov 2026" />
        <KeyValue items={[{ label: 'Order value', value: <Money value="589.00" /> }, { label: 'Commission', value: <Money value="88.35" /> }]} />
        <RowItems heading="Creator" label="Creator" items={[{ id: 1, lead: 'Sara Saeed', value: 'Open →', valueTone: 'muted', onSelect: () => {} }]} />
      </Drawer>
    </>
  );
}

PR Portal header

headerStyle="pr" gives the header the PR Portal's creator drawer look: a 64px lead avatar beside a 20px title, the 13px hint right under it, 18px above the body. The default keeps the 22px title and 12px hint.

Pinned to PR theme
Code
import { useState } from 'react';
import { Avatar, Button, Drawer, KeyValue } from '@ergasti/bricks';

function PrHeader() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open creator</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Sara Ali" hint="IG 24k · TikTok 61k" lead={<Avatar name="Sara Ali" seed={3} size="lg" />} headerStyle="pr"
        footer={<><Button>Reject</Button><Button variant="ink">Approve</Button></>}>
        <KeyValue items={[{ label: 'On TRNDR since', value: 'Mar 2025' }, { label: 'Brands', value: 'Nile Threads' }]} />
      </Drawer>
    </>
  );
}

Floating close button

With hideTitle, closeButton="float" hangs the close button over the top end of the body instead of giving it a row of its own, so a head you compose starts at the top of the drawer beside it (the PR Portal's creator drawer, with its chips under the name). footerDivider draws a line over the footer, 14px from the content and from the buttons, as that drawer's Reject / Approve.

Pinned to PR theme
Code
import { useState } from 'react';
import { Avatar, Button, Drawer, KeyValue, Pill } from '@ergasti/bricks';

function FloatingClose() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open creator</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Sara Ali" hideTitle closeButton="float" footerDivider
        footer={<><Button>Reject</Button><Button variant="ink">Approve</Button></>}>
        <div style={{ display: 'flex', gap: 14, alignItems: 'center' }}>
          <Avatar name="Sara Ali" seed={3} size="lg" />
          <div><b style={{ fontSize: 20 }}>Sara Ali</b><div style={{ fontSize: 13 }}>IG 24k · TikTok 61k</div><Pill tone="ok">Active</Pill></div>
        </div>
        <KeyValue items={[{ label: 'On TRNDR since', value: 'Mar 2025' }, { label: 'Brands', value: 'Nile Threads' }]} />
      </Drawer>
    </>
  );
}

Props

Prop

Type

Design guidance

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

The floating side panel that opens a record's details over the page (a creator, an order, a product, a payout); use it whenever a row or card opens more detail without leaving the list.

Drawer is the mock's .drawer: 400px wide, inset 12px from the edges, radius 24, sliding in from the inline end (the left in Arabic) over a 35 % scrim. It is a modal dialog: focus moves in on open, Tab is trapped, Escape, the scrim and the round × all close it, and focus returns to the opener. While open, everything outside it is made inert. loading shows one skeleton in the body while the record loads, keeping the same mounted node so it slides in once (pair with useDrawerResource).

Anatomy

  1. Scrim (button.kit-scrim--drawer, aria-hidden, not tabbable): click to close.
  2. Panel (div.kit-drawer, role="dialog", aria-modal, aria-labelledby): fixed, 12px inset, 24px padding, 16px gap, scrolls.
  3. Header row (.kit-dlg-h): lead (an avatar or thumb), title (h2, 22/700) with hint under it, aside, close × (36px round --soft, named "Close").
  4. Body (.kit-dlg-b): children, or DialogSkeleton while loading.
  5. Footer (.kit-dlg-f, optional): end-aligned buttons; with footerDivider, a 1px line above.

Variants

PropValueLookWhen
size'default'400px (--drawer-w)Most drawers
size'wide'560pxA video player and its decision form
headerStyle'default'22px title over 12px hint, 62px leadBrand drawers
headerStyle'pr'64px lead 14px before a 20px title, hint right under, 18px above bodyPR Portal creator drawer
hideTitletrueTitle kept as the accessible name, not drawn; the body starts with its own head (DrawerHead)ChallengeDetail, CreatorProfilePanel
closeButton'row' (default) / 'float'With hideTitle: close in its own row, or floated over the content's top endPR mock's floated .x
footerDividertrueLine over the footer (14px each side)PR creator drawer Reject / Approve

States

StateTriggerLook
Closedopen={false}Renders nothing
OpenopenSlides in (--drawer-dur 200ms, --drawer-ease), scrim fades in
LoadingloadingBody is one skeleton; aria-busy
Long contenttall bodyThe panel scrolls as a whole; the footer follows the content and is not pinned to the bottom, so on a long body it scrolls into view at the end
Nesteda Modal opened from the drawerOnly the outermost dialog makes the page inert; the modal sits above (z 81 vs 71)
Focus-visibleTabFocus stays inside; close × has the shared ring

Usage

A creator drawer from the table, loaded with useDrawerResource:

interface Creator { id: number; name: string }
interface CreatorDetail { joined: string; coupon: string }
const rows: Creator[] = [{ id: 1, name: 'Karim Hosny' }, { id: 2, name: 'Laila Saeed' }];
const columns: DataColumn<Creator>[] = [{ key: 'name', label: 'Creator', primary: true, render: (c) => <b>{c.name}</b> }];

function CreatorsWithDrawer() {
  const [shown, setShown] = useState<{ id: number; name: string } | null>(null);
  const drawer = useDrawerResource<CreatorDetail, { id: number; name: string }>(shown ? `/creators/${shown.id}` : null, shown);
  return (
    <>
      <DataTable label="My creators" rows={rows} rowKey={(c) => c.id} columns={columns} onRowClick={(c) => setShown({ id: c.id, name: c.name })} />
      <Drawer open={drawer.open} loading={drawer.loading} onClose={() => setShown(null)} title={drawer.seed?.name ?? ''}
        lead={drawer.seed && <Avatar name={drawer.seed.name} seed={drawer.seed.id} size="lg" />}
        footer={<><Button>Open Laila’s profile</Button><Button variant="ink">Download PDF</Button></>}>
        {drawer.data && <KeyValue items={[{ label: 'Joined', value: drawer.data.joined }, { label: 'Coupon', value: <CouponChip code={drawer.data.coupon} copyable /> }]} />}
      </Drawer>
    </>
  );
}

A drawer whose body draws its own head:

function GroupDrawer() {
  const [shown, setShown] = useState(true);
  return (
    <Drawer open={shown} onClose={() => setShown(false)} title="Ramadan glow squad" hideTitle>
      <DrawerHead tone="lime" title="Ramadan glow squad" sub="4 creators" />
      <KeyValue items={[{ label: 'Commission', value: '20% of sale' }, { label: 'Sales', value: <Money value="48210.00" /> }]} />
    </Drawer>
  );
}

An order drawer with a timeline:

<Drawer open title="Order #48211" hint="13 Nov 2026" onClose={close}>
  <KeyValue items={[{ label: 'Order value', value: <Money value="1850.00" /> }, { label: 'Commission', value: <Money value="277.50" /> }]} />
  <StepTimeline label="Where the commission is" steps={steps} />
</Drawer>

Where it appears

  • Brand › Creators › creator drawer; Find creators › profile; Creators › Groups › group drawer.
  • Brand › Payments › order and payout drawers; Analytics › product drawer; Motivation › challenge and gift order drawers.
  • PR Portal › Creators › creator drawer (headerStyle="pr", footerDivider); Approvals review.
  • Screens: Creators, Find creators, Payments › Wallet, Analytics, Motivation, PR · Creators.

Guidelines

Do

  • Open it from the row with onRowClick; show the row's data immediately (seed) and load the rest.
  • Keep the footer to the record's 1–2 main actions.
  • Use hideTitle with DrawerHead when the head needs a tone tile.

Don't

  • Don't stack two drawers; open a Modal from a drawer instead.
  • Don't use it for confirmations; use Modal.

RTL and Arabic

  • Slides in from the inline end: the left edge in Arabic (the preview's Arabic example), with the close × at the top left and the header and footer mirrored.
  • Pass Arabic for every string you give it; it translates only its own "Close" and "Loading…".

Tokens

--drawer-w, --drawer-dur, --drawer-ease, --card, --ink, --soft, --line, --dlg-title-fs, --dlg-title-fw.

Accessibility

  • role="dialog" + aria-modal="true", named by the title (also with hideTitle, where it is visually hidden). hint is not linked with aria-describedby.
  • Focus moves to the first focusable element on open (the close ×, unless lead or aside holds a control), is trapped, and returns to the opener on close. Escape closes the top layer first (a Modal over the drawer closes before it).
  • Outside content is inert and aria-hidden while open, and the page does not scroll.
  • The close × is named "Close" / "اقفل": 36px on desktop, 44px on touch screens (≤1024px). The scrim is a hidden, untabbable button for pointer users.
  • Loading: aria-busy on the dialog and one role="status" skeleton named "Loading…".

Found in the source

  • Roles in the markup: status, dialog.
  • ARIA attributes set: aria-label, aria-hidden, aria-modal, aria-labelledby, aria-busy.
  • It traps focus while open and returns it on close.
  • It locks the page behind it (inert, no scroll) while open.
  • Its tests cover: “is a light, labelled modal dialog with a labelled close button and a scrim”; “moves focus in, traps Tab, closes on Escape and returns focus to the opener”.

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

See also: useFocusTrap · useModalLock · Button · Avatar · KeyValue · Money · Pill · RowItems · DetailsBars

Source

src/kit/Dialog.tsx (line 92) on GitHub.

On this page