Html helper functions for Hyperapp. Use as an alternative to the built-in h()
function.
Install with npm or Yarn.
npm i @hyperapp/html
Then with a module bundler like Rollup or Webpack, use as you would anything else.
import { h1, div, a } from "@hyperapp/html"
Or download directly from unpkg or jsDelivr.
<script src="https://unpkg.com/@hyperapp/html"></script>
The find the library in window.html
.
const { h1, div, a } = html
const node = h1({ id: "title" }, "Hi.")
app({
state: {
count: 0
},
view: (state, actions) =>
main([
h1({}, state.count),
button({
onclick: actions.down,
disabled: state.count <= 0
}, "—"),
button({
onclick: actions.up
}, "+")
]),
actions: {
down: state => ({ count: state.count - 1 }),
up: state => ({ count: state.count + 1 })
}
})
@hyperapp/html is MIT licensed. See LICENSE.