html
Create DOM elements using a simple proxy object and functions.
import { html } from '@hellajs/dom';
const form = html.div( html.input({ type: 'text', placeholder: 'Enter your name', className: 'input-field', required: true }), html.button({ type: 'submit', className: 'btn primary', onclick: (e) => { console.log('Button clicked!', e); e.preventDefault(); } }, 'Submit'));
Raw HTML
Section titled “Raw HTML”You can inject raw HTML strings into an element using the html
prop. This bypasses normal element creation and directly inserts the HTML into the DOM.
import { html } from '@hellajs/dom';
// Insert raw HTML contentconst content = html.div({ html: '<p class="highlight">This is <strong>raw HTML</strong></p>'});
// ❌ DANGEROUS - Never do this with user inputconst userInput = getUserInput(); // Could contain malicious scriptshtml.div({ html: userInput }); // XSS vulnerability!