Skip to Content

Dialog

The Dialog component serves as a pop-up or modal window that overlays the main content, allowing the display of important messages, forms, or user interactions while grabbing user’s focus.

Usage

The Dialog component uses a slot-based API for its structure. Use DialogHeader, DialogContent, and DialogFooter as child components to compose your dialog:

import { Dialog, DialogHeader, DialogContent, DialogFooter } from 'reablocks'; <Dialog open={open} onClose={() => setOpen(false)}> <DialogHeader>Dialog Title</DialogHeader> <DialogContent> {/* Your content here */} </DialogContent> <DialogFooter> {/* Footer actions here */} </DialogFooter> </Dialog>

All three slots are optional - you can use any combination of them based on your needs.

Examples

Basic Dialog

Custom Animation

Define custom animations for the dialog, using the animation, animationViewChange props:

Learn more about how to customize the animations in the Custom Animations section.

Theme

This component uses the following default theme:

  • root{}(5 keys)
      Show all

Learn more about how to customize in the Theme documentation.

API

NameTypeDefault
classNamestring

The CSS class name for the root element of the component.

innerClassNamestring

The CSS class name for the inner content element of the component.

contentClassNamestring

The CSS class name for the content of the component.

sizestring | number

The size of the dialog. Can be a string or a number.

'50%'
showCloseButtonboolean

Whether to show the close button in the dialog header.

true
childrenReactNode | (() => ReactNode)

The content of the dialog. Supports slot-based approach with DialogHeader, DialogContent, and DialogFooter.

disablePaddingboolean

Whether to disable padding for the dialog content.

false
headerElementReactElement<DialogHeaderProps, ForwardRefExoticComponent<DialogHeaderProps & RefAttributes<HTMLElement>>> | null

The React element for the dialog header. Deprecated: Use DialogHeader slot component instead.

<DialogHeader />
themeDialogTheme

Theme for the Dialog.

initialboolean | TargetAndTransition | VariantLabels

Deprecated: Use animation configuration instead.

animateboolean | TargetAndTransition | VariantLabels

Deprecated: Use animation configuration instead.

exitTargetAndTransition | VariantLabels

Deprecated: Use animation configuration instead.

transitionTransition

Deprecated: Use animation configuration instead.

animationMotionNodeAnimationOptions

Animation configuration for the dialog.

openboolean

If true, the global overlay is open.

closeOnBackdropClickboolean

If true, the global overlay will close when the backdrop is clicked.

true
hasBackdropboolean

If true, the global overlay will have a backdrop.

true
backdropClassNamestring

The CSS class name to be applied to the backdrop of the global overlay.

closeOnEscapeboolean

If true, the global overlay will close when the escape key is pressed.

true
onClose() => void

A function that is called when the global overlay is closed.

Last updated on