Loading...
Loading...
Create interactive dialogs and modal windows in React with Syncfusion DialogComponent. Implement modal/modeless dialogs with custom positioning, dragging, resizing, animations, templating, and keyboard navigation. Use this skill whenever the user needs to display dialog boxes, modal windows, confirmation prompts, forms in popups, floating panels, or complex windowed interactions.
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-dialog@syncfusion/ej2-react-popupsimport React, { useRef, useState } from 'react';
import { DialogComponent } from '@syncfusion/ej2-react-popups';
import '@syncfusion/ej2-base/styles/material.css';
import '@syncfusion/ej2-buttons/styles/material.css';
import '@syncfusion/ej2-popups/styles/material.css';
export default function App() {
const dialogRef = useRef(null);
const [isOpen, setIsOpen] = useState(false);
const handleOpen = () => {
dialogRef.current?.show();
setIsOpen(true);
};
const handleClose = () => {
dialogRef.current?.hide();
setIsOpen(false);
};
const buttons = [
{
buttonModel: {
content: 'OK',
cssClass: 'e-flat',
isPrimary: true,
},
click: handleClose,
},
{
buttonModel: {
content: 'Cancel',
cssClass: 'e-flat',
},
click: handleClose,
},
];
return (
<div id="dialog-target" style={{ position: 'relative', width: '100%', minHeight: '400px' }}>
<button onClick={handleOpen} className="e-control e-btn e-primary">
Open Dialog
</button>
<DialogComponent
ref={dialogRef}
header="Confirm Action"
buttons={buttons}
showCloseIcon={true}
target="#dialog-target"
width="400px"
isModal={true}
visible={false}
>
<p>Are you sure you want to proceed with this action?</p>
</DialogComponent>
</div>
);
}const buttons = [
{
buttonModel: { content: 'Delete', cssClass: 'e-flat e-danger', isPrimary: true },
click: () => { performDelete(); dialogRef.current?.hide(); }
},
{
buttonModel: { content: 'Cancel', cssClass: 'e-flat' },
click: () => dialogRef.current?.hide()
}
];<DialogComponent header="Edit Profile" buttons={buttons} isModal={true} width="500px">
<div style={{ padding: '16px' }}>
<input type="text" placeholder="Name" className="form-control" />
<input type="email" placeholder="Email" className="form-control" />
<textarea placeholder="Bio" className="form-control"></textarea>
</div>
</DialogComponent><DialogComponent
header="Alert"
position={{ X: 'center', Y: 'center' }}
isModal={true}
showCloseIcon={true}
width="350px"
>
This dialog is centered on the screen.
</DialogComponent><DialogComponent
header="Properties"
isModal={false}
allowDragging={true}
position={{ X: 200, Y: 150 }}
width="300px"
enableResize={true}
resizeHandles={['All']}
showCloseIcon={true}
>
Drag me around! I don't block the page.
</DialogComponent><DialogComponent
header="Welcome"
animationSettings={{ effect: 'Zoom', duration: 400, delay: 0 }}
isModal={true}
position={{ X: 'center', Y: 'center' }}
width="400px"
>
This dialog zooms in smoothly!
</DialogComponent><DialogComponent
header="Custom Footer"
isModal={true}
footerTemplate={
<div style={{ padding: '12px', textAlign: 'right' }}>
<button className="e-control e-btn e-primary" style={{ marginRight: '8px' }}>
Save
</button>
<button className="e-control e-btn">Cancel</button>
</div>
}
>
Dialog content with custom footer.
</DialogComponent>const childDialogRef = useRef(null);
<DialogComponent header="Parent" isModal={true} width="400px">
<button onClick={() => childDialogRef.current?.show()} className="e-control e-btn">
Open Child Dialog
</button>
<DialogComponent
ref={childDialogRef}
header="Child"
isModal={true}
width="300px"
visible={false}
>
Nested dialog content
</DialogComponent>
</DialogComponent>| Prop | Type | Description | Default | When to Use |
|---|---|---|---|---|
| boolean | Enable modal mode (blocks parent interaction) | false | Confirmations, alerts, critical actions |
| boolean | Initial visibility state | false | Control initial dialog display |
| string | JSX | Dialog header/title | - | Every dialog needs a title |
| string | HTML | JSX | Dialog body content | - | Main dialog information |
| ButtonPropsModel[] | Action buttons in footer | - | For OK/Cancel, action confirmations |
| JSX | Custom footer content | - | When buttons prop doesn't fit |
| boolean | Show close button in header | false | Allow users to dismiss |
| PositionData | X/Y positioning (center, top, etc.) | { X: 'center', Y: 'center' } | Custom placement |
| boolean | Enable drag functionality | false | Movable dialogs, floating panels |
| boolean | Enable resize with grip | false | Resizable dialogs |
| ResizeDirections[] | Which edges/corners resize | ['All'] | Control resize behavior |
| string | number | Dialog width | '330px' | Control dialog size |
| string | number | Dialog height | 'auto' | Control dialog size |
| string | number | Minimum height | - | Prevent too-small resize |
| AnimationSettingsModel | Animation effect/duration/delay | - | Smooth open/close transitions |
| boolean | Close on Escape key press | true | Keyboard navigation |
| string (selector) | Container element | document.body | Modal positioning |
| boolean | Sanitize HTML content | true | Security (prevent XSS) |
| string | Custom CSS classes | - | Styling and theming |
| boolean | Right-to-left rendering | false | RTL languages |
| string | Culture/language code | 'en-US' | Localization |
| number | Stack order | - | Manage overlapping dialogs |
| boolean | Persist state on reload | false | Remember size/position |