Loading...
Loading...
Comprehensive guide for implementing Syncfusion React Notification components including Message, Skeleton and Toast and Spinner. Use this when showing informational, success, warning, or error messages; configuring severity levels and display variants (Text, Outlined, Filled); handling message dismissal; toast positioning, toast templates, toast animations; displaying skeleton loading placeholders with shimmer animations (Wave, Pulse, Fade) and shapes (Circle, Rectangle, Text); or customizing notification appearance and accessibility.
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-notificationsToastUtility@syncfusion/ej2-react-notificationsToastComponentcreatedtitlecontenttargetshowCloseButtonshowProgressBarprogressDirectionnewestOnTopwidthheighttimeOutextendedTimeouttimeOut: 0clickToCloseclickbeforeClosetemplateshow()e-toast-successe-toast-infoe-toast-warninge-toast-dangeranimationshowhideToastUtility.show()InformationSuccessErrorWarningToastModelToastUtility.show()beforeOpenbeforeOpenbeforeOpencloserole="alert"aria-live="assertive"aria-labelenableRtlshow()hide()beforeOpenopenclickbeforeCloseclosecreateddestroyedbeforeSanitizeHtmlimport { ToastComponent } from '@syncfusion/ej2-react-notifications';
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-notifications/styles/tailwind3.css';
import { useRef } from 'react';
function App() {
const toastRef = useRef<ToastComponent>(null);
return (
<>
<button onClick={() => toastRef.current?.show()}>Show Toast</button>
<ToastComponent
ref={toastRef}
title="Success!"
content="Your changes have been saved."
cssClass="e-toast-success"
position={{ X: 'Right', Y: 'Bottom' }}
timeOut={4000}
showProgressBar={true}
showCloseButton={true}
/>
</>
);
}import { ToastUtility } from '@syncfusion/ej2-react-notifications';
// Show a success toast instantly
ToastUtility.show('File saved successfully', 'Success', 3000);
// Show an error toast
ToastUtility.show('Connection failed', 'Error', 5000);cssClasse-toast-successe-toast-infoe-toast-warninge-toast-dangertimeOut: 0showCloseButton: truebuttonsbeforeOpenbeforeOpenelement.childElementCountMessageComponent@syncfusion/ej2-react-notificationsMessageComponentcontentseverityvariantshowIcontruecssClassshowCloseIconfalseclosedvisiblee-content-centere-content-rightcssClasscontentenableRtlenablePersistencerole=alertaria-labeldestroygetPersistDataclosedcreateddestroyedMessageCloseEventArgsSeverityVariantnpm install @syncfusion/ej2-react-notifications --save/* src/App.css */
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-react-notifications/styles/tailwind3.css';import { MessageComponent } from '@syncfusion/ej2-react-notifications';
import './App.css';
function App() {
return (
<MessageComponent content="Please read the comments carefully" />
);
}
export default App;<MessageComponent content="Editing is restricted" />
<MessageComponent content="Operation completed" severity="Success" />
<MessageComponent content="Read these notes" severity="Info" />
<MessageComponent content="Check your connection" severity="Warning" />
<MessageComponent content="Submission failed" severity="Error" /><MessageComponent content="Editing is restricted" variant="Filled" />
<MessageComponent content="Operation completed" severity="Success" variant="Outlined" />
<MessageComponent content="Submission failed" severity="Error" variant="Filled" />import { useState } from 'react';
function App() {
const [visible, setVisible] = useState(true);
return (
<MessageComponent
content="Your session will expire soon"
severity="Warning"
showCloseIcon={true}
visible={visible}
closed={() => setVisible(false)}
/>
);
}const contentTemplate = () => (
<div>
<h4>Build succeeded</h4>
<p>All 42 tests passed.</p>
</div>
);
<MessageComponent content={contentTemplate} severity="Success" />SkeletonComponent@syncfusion/ej2-react-notifications@syncfusion/ej2-react-notificationsSkeletonComponentheightwidthshape"Circle""Square""Rectangle""Text"shimmerEffect"Wave""Pulse""Fade"cssClassvisiblerole="status"aria-labelaria-livearia-busylabelenableRtlprefers-reduced-motioncssClassenablePersistenceenableRtlheightlabellocaleshapeshimmerEffectvisiblewidthdestroy()SkeletonTypeShimmerEffectnpm install @syncfusion/ej2-react-notifications --save/* src/App.css */
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-notifications/styles/tailwind3.css";import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from 'react';
import './App.css';
function App() {
return (
<SkeletonComponent height="15px" width="100%" />
);
}
export default App;import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from 'react';
function ProfileCardSkeleton() {
return (
<div style={{ display: 'flex', alignItems: 'center', gap: '12px', padding: '16px' }}>
{/* Avatar placeholder */}
<SkeletonComponent shape="Circle" width="48px" />
{/* Name and subtitle placeholders */}
<div style={{ flex: 1 }}>
<SkeletonComponent width="60%" height="15px" />
<br />
<SkeletonComponent width="40%" height="12px" />
</div>
</div>
);
}
export default ProfileCardSkeleton;import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from 'react';
function DataCard() {
const [loading, setLoading] = React.useState(true);
const [content, setContent] = React.useState('');
React.useEffect(() => {
setTimeout(() => {
setContent('Data loaded successfully');
setLoading(false);
}, 2000);
}, []);
return (
<div>
{loading ? (
<SkeletonComponent width="80%" height="20px" />
) : (
<p>{content}</p>
)}
</div>
);
}
export default DataCard;import { SkeletonComponent } from '@syncfusion/ej2-react-notifications';
import * as React from 'react';
function ListSkeleton() {
return (
<ul style={{ listStyle: 'none', padding: 0 }}>
{[1, 2, 3].map((i) => (
<li key={i} style={{ display: 'flex', gap: '10px', marginBottom: '12px' }}>
<SkeletonComponent shape="Circle" width="40px" shimmerEffect="Pulse" />
<div style={{ flex: 1 }}>
<SkeletonComponent width="70%" height="14px" shimmerEffect="Pulse" />
<br />
<SkeletonComponent width="45%" height="12px" shimmerEffect="Pulse" />
</div>
</li>
))}
</ul>
);
}
export default ListSkeleton;| Prop | Type | Default | Purpose |
|---|---|---|---|
| | | Skeleton shape variant |
| | | Width; required for Circle/Square |
| | | Height; used for Rectangle/Text |
| | | Animation style |
| | | Show/hide skeleton |
| | | Custom CSS class(es) |
| | | ARIA label for accessibility |
| | | Right-to-left rendering |
| | | Persist state across reloads |
npm install @syncfusion/ej2-react-popupscreateSpinnershowSpinnersetSpinnerSpinnerTypewidthfinallycreateSpinner(args: SpinnerArgs)showSpinner(container: HTMLElement)hideSpinner(container: HTMLElement)setSpinner(args: SetSpinnerArgs)SpinnerArgsSetSpinnerArgsSpinnerTypecssClasswidthtemplatesetSpinneraria-busyaria-livetype: 'HighContrast'import { createSpinner, showSpinner } from '@syncfusion/ej2-react-popups';
import * as React from 'react';
import { useEffect } from 'react';
import './App.css';
function App() {
useEffect(() => {
createSpinner({
target: document.getElementById('container') as HTMLElement
});
showSpinner(document.getElementById('container') as HTMLElement);
}, []);
return (
<div id="container" style={{ height: '200px' }} />
);
}
export default App;import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-react-popups';
import { useEffect, useRef, useState } from 'react';
function DataLoader() {
const ref = useRef<HTMLDivElement>(null);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (ref.current) {
createSpinner({ target: ref.current, label: 'Loading...' });
}
}, []);
const load = async () => {
setLoading(true);
showSpinner(ref.current as HTMLElement);
try {
await fetchData();
} finally {
hideSpinner(ref.current as HTMLElement);
setLoading(false);
}
};
return (
<div>
<button onClick={load} disabled={loading}>Load Data</button>
<div ref={ref} style={{ height: '200px', position: 'relative' }} />
</div>
);
}import { setSpinner } from '@syncfusion/ej2-react-popups';
// Call BEFORE any createSpinner — sets global default type
setSpinner({ type: 'Bootstrap5' });const fetchWithSpinner = async (container: HTMLElement) => {
showSpinner(container);
try {
const data = await fetch('/api/data').then(r => r.json());
return data;
} finally {
hideSpinner(container); // Always hide, even on error
}
};useEffect(() => {
if (!ref.current) return;
if (isLoading) {
showSpinner(ref.current);
} else {
hideSpinner(ref.current);
}
}, [isLoading]);useEffect(() => {
createSpinner({ target: document.body, label: 'Initializing...' });
showSpinner(document.body);
initializeApp().finally(() => hideSpinner(document.body));
}, []);createSpinner({
target: el,
type: 'Fluent2',
width: '40px',
label: 'Processing...',
cssClass: 'my-overlay'
});| Function | Signature | Purpose |
|---|---|---|
| | Initialize spinner on DOM element |
| | Show an existing spinner |
| | Hide a visible spinner |
| | Set global defaults for all spinners |
targetwidthlabelcssClasstemplatetype'Material''Material3''Fabric''Bootstrap''Bootstrap4''Bootstrap5''HighContrast''Tailwind''Tailwind3''Fluent''Fluent2'SpinnerComponentimport { SpinnerComponent }createSpinnershowSpinnerhideSpinnersetSpinnercolorsizevisibleisLoadingtargetwidthlabelcssClasstemplatetypecreateSpinnershowSpinneruseEffecthideSpinnerfinally| Issue | Solution |
|---|---|
| Spinner not showing | Ensure |
| Spinner stays visible | Call |
| No animation | Verify both |
| TypeScript error | Cast: |
| Spinner outside bounds | Add |
| Wrong theme | Set |
undefined