Tonic — A thin wrapper around Web Components

A Low Profile Component Framework – Stable, minimal, easy to audit, zero-dependencies and build-tool-free. Basic component definition is really simple: import Tonic from “https://cdn.skypack.dev/@optoolco/tonic” class MyGreeting extends Tonic { render () { return this.html&grave;<div>Hello, ${this.props.name ?? ‘Stranger’}.</div>&grave; } } Tonic.add(MyGreeting); Tonic will automatically convert the CamelCased class name to the proper custom element name. <my-greeting></my-greeting> …


This content originally appeared on Bram.us and was authored by Bramus!

A Low Profile Component Framework – Stable, minimal, easy to audit, zero-dependencies and build-tool-free.

Basic component definition is really simple:

import Tonic from "https://cdn.skypack.dev/@optoolco/tonic"

class MyGreeting extends Tonic {
  render () {
    return this.html`<div>Hello, ${this.props.name ?? 'Stranger'}.</div>`
  }
}

Tonic.add(MyGreeting);

Tonic will automatically convert the CamelCased class name to the proper custom element name.

<my-greeting></my-greeting>
<my-greeting name="Bramus"></my-greeting>

Here’s the code above running on CodePen:

See the Pen
Tonic Web Components Demo
by Bramus (@bramus)
on CodePen.

Also comes with an SSR package.

Tonic →
Tonic (GitHub) →
Tonic SSR (GitHub) →


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2021-10-22T00:00:55+00:00) Tonic — A thin wrapper around Web Components. Retrieved from https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/

MLA
" » Tonic — A thin wrapper around Web Components." Bramus! | Sciencx - Friday October 22, 2021, https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/
HARVARD
Bramus! | Sciencx Friday October 22, 2021 » Tonic — A thin wrapper around Web Components., viewed ,<https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/>
VANCOUVER
Bramus! | Sciencx - » Tonic — A thin wrapper around Web Components. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/
CHICAGO
" » Tonic — A thin wrapper around Web Components." Bramus! | Sciencx - Accessed . https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/
IEEE
" » Tonic — A thin wrapper around Web Components." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/. [Accessed: ]
rf:citation
» Tonic — A thin wrapper around Web Components | Bramus! | Sciencx | https://www.scien.cx/2021/10/22/tonic-a-thin-wrapper-around-web-components/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.