Modal-style slide menu with animation, backdrop, and dynamic content
Basic Slide Menu
A simple slide menu triggered by a button click. On mobile it slides up from the bottom;
on desktop it fades in centered. Uses new Sadrazam.SlideMenu({ ... })
new Sadrazam.SlideMenu({
selector: '#trigger-dom',
backdrop: true,
content: () => document.querySelector('#dom-source')
// Child nodes are moved into the menu on open,// and moved back to the source on close.
});
Programmatic Close & Destroy
You can close a slide menu programmatically from any element inside it
by calling Sadrazam.SlideMenu.remove(element).
For full teardown use Sadrazam.SlideMenu.destroy(element) or
instance.destroy() — this closes the menu, removes the trigger listener,
and clears the instance reference.
It walks up the DOM to find the nearest [data-slide-menu-id] container.
Use SlideMenu.getInstance(element) to retrieve the instance from any child element.
Static removeSlideMenu.remove(el)
// Inside the content, a button calls SlideMenu.remove(this):content: () => `
...
<button onclick="Sadrazam.SlideMenu.remove(this)">
Close from inside
</button>
`
Rich Content Menu
The slide menu can hold any HTML. This example shows a settings panel
with icons and grouped options using the built-in
.slide-menu-option-container and
.slide-menu-option-item classes.
Settings panel
Share panel
Selector Types
The selector config accepts either a CSS selector string
or a direct DOM Element reference.
CSS stringselector: '#trigger-css-sel'
Element refselector: document.getElementById(...)
// CSS selector stringnew Sadrazam.SlideMenu({ selector: '#my-button', ... });
// Direct Element referenceconst el = document.getElementById('my-button');
new Sadrazam.SlideMenu({ selector: el, ... });
Configuration Reference
All available options for new Sadrazam.SlideMenu(config).
Call Sadrazam.SlideMenu.help() in the console for a quick summary.
selectorCSS selector string or DOM Element. Required.
triggerEvent name to listen for. Default: 'click'
backdropShow backdrop overlay. Default: false
contentFunction returning HTML string or DOM Element. Required. Receives (triggerEl, instance)
openFuncCallback fired before the menu opens. Default: () => {}
closeFuncCallback fired after close animation ends. Default: () => {}
// Static methods
Sadrazam.SlideMenu.help(); // Print config reference to console
Sadrazam.SlideMenu.remove(element); // Close menu containing the element
Sadrazam.SlideMenu.destroy(element); // Full teardown: close + remove trigger listener
CSS Structure
The DOM structure and CSS classes generated by SlideMenu.
Animation classes .in / .out are
added automatically during open and close transitions.
Container.slide-menuFixed-position wrapper (full-width on mobile, centered on desktop)