Sugar to create a widget

npm install dom-widget
1 downloads in the last day
1 downloads in the last week
9 downloads in the last month


browser support

Sugar to create a widget


A widget in this case is a combination of a HTML string and an JavaScript implementation.

Widget returns a function which when called will create a new elements hash from unpack-html using the given HTML template and pass it to you.

The value you return will be passed through but if it doesn't have a view property then a view property will be set to be elements.root

var events = require("dom-reduce/event")
var fold = require("reducers/fold")
var document = require("global-scope/document")
var console = require("console")

var Widget = require("dom-widget")

var html = "<div><input data-marker='foo' /></div>"

var widget = Widget(html, function (elements, data) {
    console.log("args", arguments) = data

    return events(, "keypress")

var item = widget("hello world")

fold(item, function (event) {
    console.log("keypress events", event)
    // keypress events


npm install dom-widget


  • Raynos

MIT Licenced

npm loves you