Fluxo UIFluxo UIv0.4.1

Drawer

A slide-in panel component with four positions, focus trapping, backdrop, and customizable header/footer.

Basic Usage

Default Drawer

A right-side drawer with header and close button.

import { Drawer, Button } from 'fluxo-ui';

const [open, setOpen] = useState(false);

<Button onClick={() => setOpen(true)}>Open Drawer</Button>

<Drawer
  open={open}
  onClose={() => setOpen(false)}
  header="Drawer Title"
>
  <p>Drawer body content goes here.</p>
</Drawer>

Positions

Use the position prop to slide the drawer in from any edge.

Drawer Positions

Drawers can slide in from any edge: left, right, top, or bottom.

import { Drawer } from 'fluxo-ui';
import type { DrawerPosition } from 'fluxo-ui';

<Drawer open={open} onClose={close} position="left" header="Left Drawer">
  ...
</Drawer>

<Drawer open={open} onClose={close} position="top" header="Top Drawer" size="300px">
  ...
</Drawer>

<Drawer open={open} onClose={close} position="bottom" header="Bottom Drawer" size="300px">
  ...
</Drawer>

Custom Content

Add a header and footer to create structured drawer layouts with action buttons.

Custom Header & Footer

A drawer with a form, custom header, and action buttons in the footer.

import { Drawer, Button, TextInput } from 'fluxo-ui';

<Drawer
  open={open}
  onClose={() => setOpen(false)}
  header="Edit Profile"
  footer={
    <div className="flex gap-2 justify-end">
      <Button variant="default" onClick={() => setOpen(false)}>Cancel</Button>
      <Button variant="primary" onClick={handleSave}>Save</Button>
    </div>
  }
  size="480px"
>
  <form className="space-y-4">
    <TextInput label="Full Name" value={name} onChange={setName} />
    <TextInput label="Email" value={email} onChange={setEmail} />
  </form>
</Drawer>

Import

import { Drawer } from 'fluxo-ui';
import type { DrawerProps, DrawerPosition } from 'fluxo-ui';

Props

openreq
boolean

Whether the drawer is visible.

onClosereq
() => void

Called when the drawer should close.

position
'left' | 'right' | 'top' | 'bottom'"'right'"

Edge from which the drawer slides in.

size
string"'400px'"

Width (horizontal) or height (vertical) of the drawer.

backdrop
boolean"true"

Show a dark backdrop behind the drawer.

pushContent
boolean"false"

Push the main content instead of overlaying.

pushContentSelector
string

CSS selector for the element to push when pushContent is enabled. Defaults to '#root' or the first body child.

closeOnEscape
boolean"true"

Close drawer on Escape key press.

closeOnBackdropClick
boolean"true"

Close drawer when clicking the backdrop.

title
string

Plain-text title rendered as the drawer header (when no custom header is supplied) and used as the dialog's accessible name.

ariaLabel
string

Accessible name for the dialog. Use when there's no visible title.

ariaLabelledBy
string

ID of an element that labels the dialog. Overrides ariaLabel/title when set.

header
ReactNode

Header content. When provided, shows a header bar with close button.

footer
ReactNode

Footer content rendered at the bottom.

childrenreq
ReactNode

Main body content of the drawer.

className
string

Additional CSS class for the drawer panel.

Features

Four Positions

Slide in from left, right, top, or bottom with smooth CSS transitions.

Focus Trap

Tab key cycles through focusable elements within the drawer.

Push Content

Optionally push main content aside instead of overlaying.

Header & Footer

Optional header with close button and footer for action buttons.

Backdrop Control

Toggle backdrop visibility and close-on-click behavior.

Accessibility

ARIA modal role, focus restoration, and escape key handling.