Tonic is best understood as syntactic sugar over native web components. A component is declared as a class with an HTML template expressed as a template literal, plus a handful of supporting helpers. The result feels close to a React component, but needs no build process or other exotic tooling.

A Hello World and counter component is enough to show the shape of the API:

CSS-Tricks star logo

Examples and reuse

Tonic ships a large set of examples, kept in a separate repository. These can be pulled in and used directly, which gives the project a second identity: besides being a web component framework, it works somewhat like a design system.

How the alternatives compare

Tonic is not radically different from Lit, which Google backs and promotes actively. A Hello World and counter can be written in Lit as well:

petite-vue is another point of comparison, and a third option for the same demo:

For pure ease of implementation, petite-vue arguably wins: the whole thing is declarative HTML. Feature set, syntax, underlying philosophy and payload size all differ, though, and those considerations matter as much as brevity.

Over-the-wire JavaScript

Measuring the JavaScript each demo downloads, via the DevTools Network tab:

  • Tonic = 5.1 KB
  • Lit = 12.6 KB
  • petite-vue = 8.1 KB

All three are essentially the same in practice: tiny. None of them has been used here for a real project, so a comparative judgement between them is not warranted. What stands out is that all of them are pleasant to work with, particularly because none requires a build step.