node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



A set of functions that map the entire list of the W3C DOM elements. Each function returns a snabbdom vnode object.

Version Tests Stability Dependencies


This export will return a list of functions, where each function was created from a partially applied curry. Each function represents a tag in the list of W3C allowed tags, including deprecated, and experimental.

Each tag takes an optional object as an argument. If no value is given it functions like so:

import {main} from "snabbdom-helpers"
main() // <main></main> 

To give values to these tags simply pass them as keys on the object, where certain keys are special like selector. Selector allows you to easily define the DOM selector of the element, with the CSS id and class syntax:

import {p} from "snabbdom-helpers"
  selector: "#article1"
<p id="article1"></p>
import {p} from "snabbdom-helpers"
  selector: ".round"
<p class="round"></p>
import {p} from "snabbdom-helpers"
  selector: "#user1.profile.outward"
<p id="user1" class="profile outward"></p>

Content is either a String (of text) or an Array of Nodes and/or String:

import {p} from "snabbdom-helpers"
  inner: "I'm fun!"
<p>I'm fun!</p>
import {article} from "snabbdom-helpers"
import {h1} from "snabbdom-helpers"
  inner: [
    h1({inner: "Hello"})

Some tags have no content, they are called void elements. For example:

import {img} from "snabbdom-helpers"

If you give a void element any content it will throw an error:

import {meta} from "snabbdom-helpers"
meta({inner: "Hello!"}) // console.warn("No content is allowed on void element like <meta>") 

Finally you can give any other attributes to your element:

import {video} from "snabbdom-helpers"
  data: {
    id: "1"
  aria: {
    title: "A Sad Movie"
  src: "",
  loop: true
<video data-id="1" aria-title="A Sad Movie" src="" loop></video>

Because snabbdom-helpers relies on snabbdom you can also use it's special style and event syntax systems.

Here's a large example:

import {article} from "snabbdom-helpers"
import {h1} from "snabbdom-helpers"
import {p} from "snabbdom-helpers"
export default function view () {
  return article({
    data: {id: "1"},
    aria: {role: "navigation"},
    inner: [
        style: {color: "blue"},
        inner: "Hello"
      p({selector: ".red.body", inner: "World!"})

It should output (minus white-spacing):

<article data-id="1" aria-role="navigation">
  <h1 style="color: blue;">Hello</h1>
  <p class="red body">


  1. Read the Code of Conduct
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request