Short for Neat Interface for Creating Elements, NICE is a lightweight JavaScript library for dynamically creating DOM elements in a simple and intuitive way. Inspired by hyperscript and hyperscript-helpers.
#id
and .class
notation.div()
, span()
, button()
, etc., directly.Simply include the script in your project:
<script src="https://cdn.jsdelivr.net/gh/GCSBOSS/nice@0.0.1/dist/nice.min.js"></script>
const myDiv = div("Hello, world!");
document.body.appendChild(myDiv);
const buttonEl = button(".btn-primary", "Click Me");
document.body.appendChild(buttonEl);
const card = div(".card", [
h1(".title", "Welcome"),
p("This is a simple example."),
button(".btn", { onclick: () => alert("Clicked!") }, "OK")
]);
document.body.appendChild(card);
const styledDiv = div("#myDiv", { style: { color: "red", fontSize: "20px" } }, "Styled Text");
document.body.appendChild(styledDiv);
const btn = button("Click Me", { onclick: () => alert("Hello!") });
document.body.appendChild(btn);
Feel free to open issues and submit pull requests! Your contributions are welcome.
This project is licensed under the MIT License.