# vanilla-elements **Repository Path**: mirrors_WebReflection/vanilla-elements ## Basic Information - **Project Name**: vanilla-elements - **Description**: A Minimalistic Custom Elements Helper. - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-13 - **Last Updated**: 2026-01-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Vanilla Elements **Social Media Photo by [Jocelyn Morales](https://unsplash.com/@molnj) on [Unsplash](https://unsplash.com/)** 📣 This project didn't gain nearly nough attention as hoped so I've decided to extend builtins with [nonchalance](https://github.com/WebReflection/nonchalance#readme) and I suggest you check that out instead, as it doesn't rely at all to a *maybe* polyfill needed to work, it doesn't need to patch globals, and most importantly, it's half of the size of this module through its */runtime* variant. - - - A Minimalistic Custom Elements Helper, with optional polyfill included, compatible with every evergreen browser. The default module export, which is ~0.5K, works natively in Chrome, Edge, and Firefox, but if you target Safari / WebKit too, you can use the `vanilla-elements/poly` variant, which is ~2K, and it includes proper features detection, leaving Chrome, Edge, and Firefox 100% native. ```js import {define, HTML} from 'vanilla-elements'; // generic components ... or define('my-comp', class extends HTML.Element { // native Custom Elements definition }); // ... builtins extend simplified ... and define('my-div', class extends HTML.Div { // native Custom Elements definition }); // ... as decorator 🥳 @define('my-footer') class MyFooter extends HTML.Footer {} document.body.appendChild(new MyFooter); ``` ## API * the `define(name:string, Class):Class` automatically recognize the right way to define each component, either generic elements or built-ins. * the `HTML` namespace contains all available HTML classes from the browser, with shortcuts such as `Div`, `Main`, `Footer`, `A`, `P`, and everything else. **[Live Example](https://codepen.io/WebReflection/pen/jOmVVQQ?editors=0010)** ```js import {define, HTML} from 'vanilla-elements'; import {render, html} from 'uhtml'; define('h2-greetings', class extends HTML.H2 { constructor() { super(); this.html = (...args) => render(this, html(...args)); this.render(); } render() { this.html`Hello Vanilla Elements 👋`; } }); render(document.body, html`
`); ``` ## F.A.Q.