Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Modals and Drawers

Payload provides several overlay surfaces for focused actions and supporting content. The Admin Panel supplies the modal context these components use.

Import

1
import {
2
ConfirmationModal,
3
Drawer,
4
DrawerContentContainer,
5
DrawerToggler,
6
FullscreenModal,
7
Modal,
8
useModal,
9
} from '@payloadcms/ui'

Confirmation modal

Loading component example…

Give the trigger and modal the same modalSlug. Call openModal with that slug to display the modal. ConfirmationModal closes itself after onConfirm resolves or when the user cancels.

Drawer

Loading component example…

Use DrawerToggler or openModal to open a Drawer. The trigger and drawer must share the same slug.

DrawerContentContainer adds the standard content spacing used inside Payload drawers. Set gutter={false} on Drawer when the drawer's contents manage their own horizontal spacing.

Choosing a surface

  • Use ConfirmationModal to confirm a focused action.
  • Use Drawer for supporting content that should remain connected to the current view.
  • Use Modal for a custom dialog and FullscreenModal when the content needs the full viewport.
  • Use ItemsDrawer when the user needs to pick from a searchable list of Blocks or Widgets, as Payload does when adding a row to a Blocks field.
  • Use the useDocumentDrawer or useListDrawer hooks for document selection. Each returns the drawer, its toggler, and the drawer's state.

Common props

These are the props most commonly used. See the exported types in @payloadcms/ui for the complete list.

ConfirmationModal

Prop

Type

Default

Description

modalSlug *

string

Connects the modal to its trigger.

heading *

ReactNode

Displays the modal heading.

body *

ReactNode

Displays the confirmation message.

onConfirm *

() => Promise<void> | void

Runs when the user confirms the action.

onCancel

() => void

Runs after the user cancels the action.

confirmLabel

string

Replaces the translated confirm label.

confirmingLabel

string

Replaces the label shown while confirmation is pending.

cancelLabel

string

Replaces the translated cancel label.

Drawer

Prop

Type

Default

Description

slug *

string

Connects the drawer to its trigger.

title

string

Displays the default drawer heading.

children *

ReactNode

Renders the drawer content.

gutter

boolean

true

Applies Payload's horizontal gutter to the content.

Header

ReactNode

Replaces the default drawer header.

hoverTitle

boolean

Adds the title as a native tooltip on the heading.

* An asterisk denotes that a prop is required.

Provider requirements

These components use the modal, translation, and drawer-depth contexts supplied by the Payload Admin Panel. When composing them outside the Admin Panel, provide the equivalent contexts before rendering the components.

Was this page helpful?

Next

Motion and Loading