Drawer

A panel that slides in from the edge for a focused task over the page: the CRM's side panel. Built on ui-sdk's Drawer: modal, Escape or a press outside closes it, a swipe toward its edge dismisses it, and focus returns to the trigger.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerBody, DrawerFooter } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

title
subtitle
closeButton
side
icon
tone

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it for a focused task over the page, like editing a contact or reviewing an opportunity, where the page stays in place behind it.
DoGive DrawerHeader a title that names the record, like Jane Citizen, and a subtitle for what it is, like Individual · Client.
DoPut long content in DrawerBody, which scrolls under the overlay scrollbar while the header and footer stay put.
DoSet dismissible={false} while the drawer holds unsaved edits, and ask Discard changes? in onDismissAttempt: a swipe, Escape or a press outside then reports the attempt instead of closing.
Don'tTurn off closeButton. A panel needs a visible way out besides Escape and a swipe.
Don'tUse it for a quick question or a confirmation. Use Dialog, or AlertDialog for a choice that can't be undone.

Props

Drawer takes ui-sdk's options: open, defaultOpen, onOpenChange, modal, dismissible={false} with onDismissAttempt (ask "Discard changes?"), snapPoints and controller. DrawerClose takes render and value.

Drawer

PropTypeDefaultDescription
sideComponentProps<typeof DrawerRoot>["side"]"end"The edge it slides from. `end` (right in left-to-right text) for panels.

DrawerContent

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DrawerHeader

PropTypeDefaultDescription
iconReactNode—The 20 px icon in the 40 px tile on the left.
toneExclude<Tone, "default" | "plum"> | "neutral""info"The icon tile's colour, as IconTile.
title *ReactNode—Names the drawer.
subtitleReactNode—One muted line under the title, which describes the drawer.
closeButtonbooleantrueShows the round close button. Leave it on: a panel needs a visible way out.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DrawerBody

PropTypeDefaultDescription
classNamestring—Classes added to the root element, merged with its own. Tokens only.
childrenReactNode—What it shows inside.

DrawerFooter

No props of its own.

Code

What the playground shows, ready to copy.

import {
  Button,
  Drawer,
  DrawerBody,
  DrawerClose,
  DrawerContent,
  DrawerFooter,
  DrawerHeader,
  DrawerTrigger,
} from "@leap-crm/design-system";

<Drawer>
  <DrawerTrigger render={<Button intent="outline">Open drawer</Button>} />
  <DrawerContent>
    <DrawerHeader title="Jane Citizen" subtitle="Individual · Client" />
    <DrawerBody>
      <p>jane@citizen.com.au</p>
    </DrawerBody>
    <DrawerFooter>
      <DrawerClose render={<Button intent="outline">Cancel</Button>} />
      <DrawerClose render={<Button>Save</Button>} />
    </DrawerFooter>
  </DrawerContent>
</Drawer>

Long content

The body scrolls under the overlay scrollbar; the header and footer stay put.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { UserRound } from "lucide-react";

import { Button, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTrigger } from "@leap-crm/design-system";

const fields = [
  ["Email", "jane@citizen.com.au"],
  ["Phone", "0412 345 678"],
  ["Address", "14 Harbour Street, Sydney NSW 2000"],
  ["Source", "Website enquiry"],
  ["Responsible", "Ada Hartley"],
] as const;

function EditContact({ long = false }: { long?: boolean }) {
  const rows = long ? [...fields, ...fields, ...fields, ...fields] : fields;
  return (
    <Drawer>
      <DrawerTrigger
        render={
          <Button intent="outline" icon={<UserRound />}>
            {long ? "Long panel" : "Edit contact"}
          </Button>
        }
      />
      <DrawerContent>
        <DrawerHeader
          icon={<UserRound />}
          title="Jane Citizen"
          subtitle="Individual · Client"
        />
        <DrawerBody>
          <dl className="flex flex-col gap-4">
            {rows.map(([term, detail], index) => (
              <div
                key={`${term}-${String(index)}`}
                className="flex flex-col gap-1"
              >
                <dt className="text-small text-neutral-text-muted">{term}</dt>
                <dd className="text-body m-0">{detail}</dd>
              </div>
            ))}
          </dl>
        </DrawerBody>
        <DrawerFooter>
          <DrawerClose render={<Button intent="outline">Cancel</Button>} />
          <DrawerClose render={<Button>Save</Button>} />
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  );
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
TabStays inside the drawer and cycles through its controls in order.
EscapeCloses the drawer on top only.