Plugins
You can extend BetterDialog behavior by passing plugin functions via options.plugins
.
Plugin Signature
type DialogPlugin = (hooks: { onInit: (cb: (dialog: DialogItem) => void) => void; onShow: (cb: (dialog: DialogItem) => void) => void; onClose: (cb: (dialog: DialogItem) => void) => void;}) => void;
Example
const scrollLockPlugin: DialogPlugin = ({ onShow, onClose }) => { onShow((dialog) => { document.body.style.overflow = 'hidden'; }); onClose((dialog) => { document.body.style.overflow = ''; });};