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
Confirmation modal
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
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
ConfirmationModalto confirm a focused action. - Use
Drawerfor supporting content that should remain connected to the current view. - Use
Modalfor a custom dialog andFullscreenModalwhen the content needs the full viewport. - Use
ItemsDrawerwhen 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
useDocumentDraweroruseListDrawerhooks 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 |
|---|---|---|---|
| | — | Connects the modal to its trigger. |
| | — | Displays the modal heading. |
| | — | Displays the confirmation message. |
| | — | Runs when the user confirms the action. |
| | — | Runs after the user cancels the action. |
| | — | Replaces the translated confirm label. |
| | — | Replaces the label shown while confirmation is pending. |
| | — | Replaces the translated cancel label. |
Drawer
Prop | Type | Default | Description |
|---|---|---|---|
| | — | Connects the drawer to its trigger. |
| | — | Displays the default drawer heading. |
| | — | Renders the drawer content. |
| | | Applies Payload's horizontal gutter to the content. |
| | — | Replaces the default drawer header. |
| | — | 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?