Backdrop overlay: show, hide, click-to-close, and z-index stacking demos
Basic Show / Hide
Use Backdrop.insert() to show the backdrop and
Backdrop.remove(ownerId) to hide it.
The method returns an ownerId string used to remove that specific request.
ToggleHidden
// Show the backdrop const ownerId = Sadrazam.Backdrop.insert();
// Hide it by ownerId
Sadrazam.Backdrop.remove(ownerId);
Click to Close
Pass an onClick callback in the options object.
When the user clicks the backdrop, the callback fires — typically used to close the overlay.
OpenHidden
let id;
id = Sadrazam.Backdrop.insert({ onClick: () => {
Sadrazam.Backdrop.remove(id);
}
});
Custom z-index Variable
Override the CSS custom property used for z-index via the
zIndexVar option. Default is
--z-dropdown-backdrop.
You can also pass stackLevel to set --z-modal-stack-level.
Backdrop maintains an internal stack. Each insert() pushes an owner;
each remove() pops or filters it out. The backdrop stays visible until the
stack is empty. The topmost owner's onClick is the one that fires on click.
Push
Stack:(empty)
Clicking the backdrop itself removes the topmost owner (via its onClick).
Push multiple owners, then try clicking the backdrop repeatedly to watch the stack drain.