The portable port-able part of the web for the whole wide world

View Source

Tag provides a unified approach for rendering, scoped styles, event delegation, state management, and only those four things. Plainly, Tag is a trifecta of fundamental techonolgies designed to build expressive web applications.

Quick Start View Example

Hello World is a common program to write when first learning something new. The code below imports tag.js, creates a custom tag, and sets the content to 'Hello World!'

import tag from 'https://deno.land/x/tag'
tag('hello-world').render(() => 'Hello World!')

Tip! View the source of the example page to see <hello-world> in action!


const $ = tag(selector: string [, state: object]) : object

Creates an custom, scoped HTML tag. Requires a selector: a CSS selector. An optional second argument may be passed for seeding the initial state.

It will return an object with the selector as an attribute and the following namespaced functions.

$.render(function(target: EventTarget))
Expects a function that returns HTML as a string to be rendered into the provided target. A falsey return will leave the target node untouched. This function will be invoked whenever state changes.
$.style(stylesheet: string)
Expects a CSS stylesheet as a string. The ampersand (&) symbol may be used to scope rulesets.
$.on(eventType: string, selector: string, function(event)) : function
An event delegator that expects three arguments. A css selector, and a handler. No selector will listen on the tag's root. Returns a function to remove the listener when invoked.
$.read() : object
Returns the current state.
$.write(payload [, function(state, payload)])
Merges the payload into the current state. An optional second argument for managing the state update may be provided. That function will be called with the current state and the payload. It expects the reconciled, complete state to be returned

Browser Support: The tail feature set for this application is ES Modules, which is supported by all modern browsers. For an entertaining summary, please refer to Making Future Interfaces: ES Modules.


<hello-name> View Example

The Hello Name example shows the fundamentals of incorporating variables into the tag's state.

<!-- hello-name.html -->

<script type="module">
  import tag from 'https://deno.land/x/tag'

  const $ = tag('hello-name', {
    'name': 'Earth'

  $.render(() => {
    const { name } = read()

    return `Hello ${name}`
<hello-nickname> View Example
Demonstrates local two-way data binding and persisting updates across page reloads.
<hello-universe> View Example
An application for managing planet information and viewing a sequential representation of our solar system.
<hello-gallery> View Example
A static photo gallery that upgrades to a carousel with progressive enhancement.
<hello-editor> View Example
What-You-See-Is-What-You-Get style content editing with QuillJS.
<hello-map> View Example
A maplibre.org integration that incorporates live realtime data. A direct port of this example from their official docs.
<hello-reddit> View Example
A reddit integration that exposes their API over HTML. Control which subreddits are queried and how they are sorted with attributes.
<hello-launcher> View Example
An application that opens and manages other applications. Inspired by and a prototype for this forum post.
<window-pane> View Example
The foundation for a minimal window manager using a CSS stylesheet that replicates Windows 7.
<solid-user> View Example
A Solid POD authenticator. This allows people to connect to their preferred identity provider.
<todo-list> View Example
A TodoMVC application that utilizes Solid as a backend.


Inspiring people building interesting projects are everywhere. These links helped shape Tag's development by just being cool things on the internet.

About the Author

Tyler Childs is a netizen with a deep passion for the open web and radical transparency. He believes everyone can go further together and sharing knowledge is critical to group success.

You can reach him via email at [email protected] for any reason at any time. Response times may vary.

Fun fact! Tag is the final part in a now-complete solo trilogy. Vanilla HTML was a flop in 2013 and Cutestrap was a cult-hit in 2016!

Source Code

Available on GitHub under the CC BY-SA 4.0