⚡️ A better element creation function (h
) for preact
Why?
- You want to use preact with no build tool
- You are not in favor of extending the language with non-standard extensions
h
?
Why not preact's Creating and reading dom structures is the bread and butter in creating UI. It should have minimal boilerplate. Thats what this library does - removing boilerplate.
// preact // preact-element
Getting Started
With preact-element
installed (using your favourite package manager), you can
then import it. Each element
in the DOM is exposed as a function when requiring preact-element
.
Plain commonjs
const h = // -> h.div()
Destructuring
const div h1 =
ES6
Use it!
const App =
API
attributes
and children
are optional.
createElement(tag, attributes?, ...children?)
[tag](attributes?, ...children?)
Where as tag
is one of the html tags or svg tags.
Author
preact-element © Fabian Eichenberger, Released under the MIT License.
Authored and maintained by Fabian Eichenberger with help from contributors (list).