Alert Component
The toast notification system allows you to display temporary pop-up messages (toasts) with different styles (success, warning, info, error) in your application.
Last updated
npm install @questlabs/react-sdkimport { showToast } from "@questlabs/react-sdk"
import '@questlabs/react-sdk/dist/style.css'
showToast.success({
text: 'Success! Your operation was completed.',
duration: 3000,
});
// also you can just pass the string
showToast.success("Submitted successfully");showToast(<div>This is a toast element<div/>)import { showToast } from '@questlabs/react-sdk'; // Import the toast module.
function MyComponent() {
const handleSuccessClick = () => {
showToast.success({
text: 'Operation successful!',
duration: 3000,
});
};
const handleErrorClick = () => {
showToast.error({
text: 'An error occurred.',
duration: 4000,
});
//or
showToast.error("An error occurred");
};
return (
<div>
<button onClick={handleSuccessClick}>Show Success Toast</button>
<button onClick={handleErrorClick}>Show Error Toast</button>
</div>
);
}