Need help with unity-component-specification?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

214 Stars 2 Forks Apache License 2.0 6 Commits 7 Opened issues


This is a WIP draft of the Unity (Single File Web Component) Specification

Services available


Need anything else?

Contributors list

# 1,909
4 commits
# 22,343
1 commit


This is a WIP draft of the Unity (Single File Web Component) Specification


Unity Component Specification describes a new hypertext-like file format for creating Single-File Web Components (SFWC).


  • rosetta stone-like capabilities component interop between frameworks.

    • provides a promise for users, companies, lib authors to have a single "meta" description of how their "ui component" should function, meanwhile using modern tooling, and small compiler chains, could compile this "meta" information into the framework's actual representation.
  • allow users to ship way less JavaScript and CSS to the browser

  • 60fps scroll lists, fast dom changes, fast paints. "Does it beat the Ken Wheeler Test" (long term platform goal)


Giant company (A) is silo'd and has a variety of different frameworks that they use in house, and they all love the workflows that they have, however there is massive amounts of overlap because they cannot write components that both teams can use.

With "unity components" (Single File Components) this could be possible: Team A using

(Figure 1), could use this component in the same way that Team B using 'Vue' (Figure 2) does.

Figure 1: Using

file and consumed with preact
```js import {Button} from "material-unity" // returns a SFC "module" .sfc or .vue, etc whatever

render( , document.body ); ```

Figure 2: Using same

inside of a Vue single file component


The point is that the framework-specific implementation details of how this "meta information" represented in the Single File Component are hidden through the compiler toolchains.

So although you might see

function that returns state for the component, it may instead compile to
in react/preact, or
in GlimmerJS.

How this relates to the platform (the long term idea if frameworks buy in @first)

Although this statement may be opinionated, it is observed that the number one problem with web components currently is that it is a write only target, not something a framework could consume and then use (like their own systems components) without potentially substantial changes to their respective api's, renders, etc. This poses a huge challenge for adoption.

In addition, until there is cross-platform adoption for Web Components completely, there is really no interest for a majority of users or framework teams to start integrating with this system.

Abstraction not only for Frameworks, but also the Platform

The magic behind what makes Vue's single file component structure so flexible and powerful, is that everything inside of their respective tags, is only a "likeness" to some extent.

For example:


In the same way that:

   I look and smell like HTML, but I'm not html, I'm JSX, I'm html-like,

So in the same way that a loader, compiler, etc. statically analyzes a

file to create a JavaScript implementation of that components Dom API functionality (via VDOM), we can apply the same principle for the platform to accomplish the same thing.

In a real index.html file

Click Me

We have fed a single component to the browser, which consumes the SFC module, and instead of creating render functions, vdom, JSX, javascript, or anything else, it is interpreted and compiled to native instructions for the lifecycle, state, and the visual representation and behavior for that element on the DOM.

Side Notes:

Here's some things I want to clarify before they get mentioned

Template "Directives"

A huge motivation for the use of these universal directives, is the same reason why they are great in VueJs. Although at any time, in a single-file

component, a user can drop
 and instead opt-in to using 
render(, document.body)

But in the end (for vue):


is just an abstraction that compiles to VDOM/Render functions to perform that ginormous scrolling list. The benefit of the platform consuming this, is that it can read that directive as an instruction to perform the same results, but in a far more, Ken Wheeler-defying-90fps-fashion (because its not DOM, or JS, its native instructions interpreted from the file).

JSX inside of

In the same way that

 can be statically analyzed and compiled, you can take this a step further and say the use of JSX inside of 
 could have a similar outcome. 


  • Native calls are fast, no JavaScript DOM API's are called, the render, layout engines, etc. now can compile and manage these just like another implementation detail as direct "assembly like instructions" for how things must be viewed, laid out, painted et al.
  • There is no need to Custom Elements, it is native instructions, there needs to be no extension of existing elements or behaviors.
  • What might compile to a couple hundred lines of code, and be shipped inside of JS, CSS, could now be shipped in a single file, in a non blocking fashion.
  • (Maybe? I'm not an expert in the browser to understand this piece yet) patterns like
     provides a css-like scoping solution that doesn't have to rely on shadow dom, etc.
  • It doesn't rely on pieces of the existing web component specification, and browsers, (as long as its implemented), could implement this however they would like for their respective platforms, etc.
  • Using in the browser outside of the FW, could be as simple as just dropping the component into a
     and using. And this could potentially create a Rosetta Stone-like api for interop between a variety of frameworks (if not all). 
  • webpack users could still leverage their own styling and template tools/preprocessors of choice, and webpack will (if this spec is pushed, or at the least 3+ frameworks can adopt it), create an output target for
    . That way loaders can still be used to allow one to customize, extend etc while still compiling to
    in browserland.


  • Silver bullet syndrome: things that become abstracted, can lose flexibility, or have features removed to create interop. This should be carefully balanced and thought out.

  • Not all frameworks can statically compile these formats? (If not what is the MVP amount of changes that we could make to ensure that not only VDOM-frameworks, but also observer, watcher, and bind based libraries can leverage as well.

  • Can dilute the framework capabilities of a specific component type? What may work with a full rich featureset in

    , may need to have limited capabilities in GlimmerJS, or Polymer. (Or am I wrong. I don't know enough about them to make this assumption, but would like feedback on this.)
  • Pushback in browserland vs WC v2.: Although this could arise, I'm hopeful that because the

    format doesn't mandate creation of API's that affect DOM (besides a new module/script type), that this could be easily worked around, and potentially alongside WC v2.

Use Cases

Currently there are multiple JavaScript web frameworks that use an interoperable Single-File Web Component format. Not only are they a unifying formate between frameworks, but should aim to be a native platform implementation.

Unity Component Module

hello-world.ucm ```html

## Interface
This file format will support a strict subset of hypertext markup tags that will delimit and distinguish the use of JavaScript, HTML, and CSS in the single file. 

### `` tags

#### Syntax
* Any uses of valid HTML, will be valid inside of the `` tags.
* Always single element root? (like vdom'y stuff or not needed for native implementation)

#### Data Binding
* `{{ }}` will be the syntax. (should we even try to allow this to be overriden?)
* Any valid expression within braces
* `v-bind=` mentioned here?

#### Directives 
* Explain what the hell a directive does. Could this specification allow for the creation of JS directives, but all built ins are native for performance? 
* List of Built in Directives? 

### `` tags

#### Syntax
* Any uses of valid CSS is permitted inside of the `` tags.

#### Scoped? 😬

### `` tags

#### Syntax
* Any uses of valid JS is permitted inside of the `` tags.
* Must `export default` a object of properties describing available data bindings, props, computed properties, other registered UCM's, declarations and all other Unity Component Module options. 

#### UCM Options Object
* // TODO: Add all the Vue Component options here. 

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.