Web Components
Tegaki provides a <tegaki-renderer> custom element that works in any browser — no framework required.
Installation
Section titled “Installation”Register the custom element once, before using it in HTML:
Using via CDN
Section titled “Using via CDN”You can use Tegaki directly from a CDN without any build tools or package manager. This is the fastest way to get started — just add a <script> tag to any HTML page.
esm.sh (recommended)
Section titled “esm.sh (recommended)”esm.sh serves npm packages as ES modules and bundles dependencies automatically:
To pin a specific version, add it to the URL:
jsDelivr
Section titled “jsDelivr”jsDelivr can serve package files directly via its ESM endpoint:
Import maps
Section titled “Import maps”For cleaner imports, use an import map to map bare specifiers to CDN URLs:
This lets you write the same import paths you’d use with a bundler, while loading from the CDN at runtime.
Loading font data manually with createBundle
Section titled “Loading font data manually with createBundle”If the pre-built font bundles don’t work in your environment, or you want to load font data from a custom URL, use createBundle to assemble a bundle from its parts:
This is also useful for loading custom font bundles generated with the interactive generator.
Full standalone example
Section titled “Full standalone example”Here’s a complete HTML file you can save and open directly in a browser:
Basic example
Section titled “Basic example”The element uses Shadow DOM internally. Style the host element with font-size and color as usual — the renderer inherits them.
Text content
Section titled “Text content”You can set the text via the text attribute or as the element’s text content:
Controlled time
Section titled “Controlled time”Set the time attribute to a number to control the animation manually:
Playback attributes
Section titled “Playback attributes”Control uncontrolled playback via attributes:
Effects
Section titled “Effects”Effects are objects and can’t be expressed as attributes. Use the effects property instead:
Playback controls
Section titled “Playback controls”The element exposes playback methods and read-only properties:
Accessing the engine
Section titled “Accessing the engine”For advanced use cases, the underlying TegakiEngine instance is available:
CSS time mode
Section titled “CSS time mode”Use time="css" to drive the animation from CSS custom properties:
See the Rendering Animations guide for details.
Custom tag name
Section titled “Custom tag name”Custom element names must contain a hyphen per the HTML spec. The default is tegaki-renderer, but you can choose any valid name:
Attributes reference
Section titled “Attributes reference”| Attribute | Type | Description |
|---|---|---|
text | string | Text to render. Falls back to textContent if not set. |
font | string | Registered bundle name (see TegakiEngine.registerBundle). |
time | number | "css" | Controlled time in seconds, or "css" for CSS mode. Omit for uncontrolled. |
speed | number | Playback speed multiplier (default 1). |
playing | "true" | "false" | Whether animation is playing (default true). |
loop | boolean attribute | Loop animation when it finishes. |
segment-size | number | Segment size for rendering. |
show-overlay | boolean attribute | Show debug text overlay. |
Properties reference
Section titled “Properties reference”These properties are set via JavaScript and support object values that can’t be expressed as attributes:
| Property | Type | Description |
|---|---|---|
font | TegakiBundle | string | Font bundle object or registered name. |
effects | TegakiEffects | Visual effects configuration. |
timing | TimelineConfig | Timeline timing configuration. |
onComplete | () => void | Callback when animation completes. |
engine | TegakiEngine (read-only) | The underlying engine instance. |
For the full options reference, see the TegakiRenderer API docs.