Loading...
Loading...
Comprehensive guide for implementing Syncfusion React popup components including Dialog, ToolTip. Use this when building modal/modeless dialogs, confirmation popups, forms in dialogs, draggable windows, popovers, tooltips, and overlaid content with custom positioning, animations, WCAG 2.2 accessibility, forms integration, and event handling in React applications.
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-popups@syncfusion/ej2-react-popups⚠️ Dependency Alignment: Allpackages must be on the same major version to avoid peer-dependency conflicts and supply-chain mismatches. Install them together:@syncfusion/ej2-*npm install @syncfusion/ej2-react-popups @syncfusion/ej2-base @syncfusion/ej2-buttons @syncfusion/ej2-popups
import 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 |
<ejs-dialog>DialogUtility| Dialog Type | Method |
|---|---|
| Alert | |
| Confirm | |
| Prompt (input) | |
import { DialogUtility } from '@syncfusion/ej2-react-popups';import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { DialogUtility } from '@syncfusion/ej2-react-popups';
import * as React from 'react';
function App() {
function showAlert() {
DialogUtility.alert({
title: 'Low Battery',
width: '250px',
content: '10% of battery remaining',
});
}
return <ButtonComponent cssClass="e-danger" onClick={showAlert}>Alert</ButtonComponent>;
}
export default App;@syncfusion/ej2-react-popupsanimationSettingseffectdurationdelayisDraggableposition{ X, Y }left|center|righttop|center|bottomwidthheightcssClassokButtoncancelButtontexticonclickshowCloseIconcloseOnEscapecontentDialogUtility.alert()confirm()titlecontentwidthheightpositionanimationSettingsisDraggableokButtoncancelButtonshowCloseIconcloseOnEscapecssClassconst dialogObj = DialogUtility.alert({
title: 'Info',
content: 'Operation complete.',
okButton: { click: () => { dialogObj.hide(); } }
});const dialogObj = DialogUtility.confirm({
title: 'Delete?',
content: 'Are you sure?',
width: '300px',
okButton: { text: 'Yes', click: () => { dialogObj.hide(); /* do delete */ } },
cancelButton: { text: 'No', click: () => { dialogObj.hide(); } }
});const dialogObj = DialogUtility.confirm({
title: 'Enter Name',
content: '<p>Your name:</p><input id="nameInput" class="e-input" placeholder="Type here..." />',
width: '300px',
okButton: {
text: 'Submit',
click: () => {
const val = (document.getElementById('nameInput') as HTMLInputElement).value;
dialogObj.hide();
}
},
cancelButton: { click: () => dialogObj.hide() }
});TooltipComponent@syncfusion/ej2-react-popupsimport { TooltipComponent } from '@syncfusion/ej2-react-popups';npm install @syncfusion/ej2-react-popups --save/* src/App.css */
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-react-popups/styles/tailwind3.css";import * as React from 'react';
import { TooltipComponent } from '@syncfusion/ej2-react-popups';
import './App.css';
function App() {
return (
<TooltipComponent content="Tooltip Content" position="TopCenter">
<button className="e-btn">Show Tooltip</button>
</TooltipComponent>
);
}
export default App;targettitlebeforeRenderdataBind()TopLeftTopCenterTopRightBottomLeftBottomCenterBottomRightLeftTopLeftCenterLeftBottomRightTopRightCenterRightBottomshowTipPointertipPointerPositionrefresh()mouseTrailoffsetXoffsetYwindowCollisionAutoHoverClickFocusCustomopensOnopensOn="Hover Click"isStickyopenDelaycloseDelayopen()close()animationAnimationModelopen()close()beforeRendercssClasswidthheightenableRtldestroy()render()role="tooltip"aria-describedbyaria-hiddenTooltipAnimationSettingsTooltipEventArgsPositionTipPointerPosition<TooltipComponent content="Submit the form" position="TopCenter">
<button className="e-btn e-primary">Submit</button>
</TooltipComponent>// Single TooltipComponent handles all .e-info targets;
// each uses its own `title` attribute as content
<TooltipComponent target=".e-info" position="RightCenter">
<form>
<input className="e-info" type="text" title="Enter your name" />
<input className="e-info" type="email" title="Enter a valid email" />
</form>
</TooltipComponent><TooltipComponent
content="Click the × to close me"
opensOn="Click"
isSticky={true}
position="BottomCenter"
>
<button className="e-btn">Click Me</button>
</TooltipComponent>import * as React from 'react';
import { TooltipComponent } from '@syncfusion/ej2-react-popups';
function App() {
let tooltipRef: TooltipComponent;
const target = React.useRef<HTMLButtonElement>(null);
return (
<TooltipComponent
ref={t => (tooltipRef = t)}
content="Tooltip opened programmatically"
opensOn="Custom"
>
<button
ref={target}
className="e-btn"
onClick={() => {
if (target.current.getAttribute('data-tooltip-id')) {
tooltipRef.close();
} else {
tooltipRef.open(target.current);
}
}}
>
Toggle Tooltip
</button>
</TooltipComponent>
);
}<TooltipComponent
content="Following your mouse!"
mouseTrail={true}
showTipPointer={false}
>
<div style={{ width: '200px', height: '100px', background: '#eee' }}>
Hover over me
</div>
</TooltipComponent>| Prop | Type | Default | Purpose |
|---|---|---|---|
| | — | Tooltip text, HTML, or JSX template |
| | — | CSS selector for multi-target mode |
| | | 12 placement values |
| | | Hover / Click / Focus / Custom |
| | | Keep visible until user closes |
| | | Follow mouse cursor |
| | | Show/hide arrow tip |
| | | Auto / Start / Middle / End |
| | | ms delay before opening |
| | | ms delay before closing |
| | | Distance from target (px) |
| | | Tooltip dimensions |
| | | Custom CSS class |
| | FadeIn/FadeOut 150ms | Open/close animation |
| | | Right-to-left rendering |
| | | Sanitize HTML content |
| | | Popup append target |
| | | Collision vs viewport |