simple-popup-js
v1.0.0
Published
Zero-HTML confirm popup that injects its own DOM and CSS. Tiny, framework-free.
Maintainers
Readme
simple-popup
Zero-HTML confirm popup. When you import it, it injects its own DOM + CSS automatically.
- Pure VanillaJS, Framework-free, <3 KB gzipped.
- supports callback for both Yes and No click
Install
npm install -S simple-popup-jsUse (ESM)
import { customPopup, customConfirm } from 'simple-popup-js';
document.getElementById('openPopup').addEventListener('click', (e) => {
e.preventDefault();
customPopup('Really?', () => alert('Yes!'), () => console.log('No.'));
});
const ok = await customConfirm('Proceed?');
if (ok) { /* ... */ }Global (no bundler)
<script src="/node_modules/simple-popup-js/dist/global.js"></script>
<script>
window.customPopup('Hi there');
</script>Note that to trigger it for manual click you need to add a element with id="openPopup"
This is mandatory
Demo
https://codepen.io/sejan404/pen/qEOGpyJ
