AddMoreScripts/hystModal — reverse-engineered prompt

Reverse engineered prompt

GitHub

Build me a tiny, dependency free modal popup library in plain JavaScript, plus a simple demo page that shows how to use it. I want it to feel polished and lightweight, with styles controlled mostly by CSS so people can theme it however they want.

The modal should open from a data attribute on links or buttons, and also be openable from code with a small API. It should close on the overlay, Escape, or a close button, with options to turn those behaviors on or off. Please make it handle background scroll locking, keep the dialog centered, and trap keyboard focus inside while it is open, then return focus to the element that launched it. Accessibility matters, so use good dialog semantics and aria attributes.

Please avoid rewriting the page DOM in a way that would break existing event listeners inside the modal content. Add simple callbacks for before open and after close. Include a built version and a clear example in the demo page. You can check current browser friendly modal patterns online if needed.

Want more depth? Deep Reverse