typing-text
Text typed out a letter at a time with a blinking caret, starting when it scrolls into view. Screen readers get the whole text at once; reduced motion shows it typed.
This one has no events: it shows what it's given.
Source: typing-text.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/typing-text.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/typing-text.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/typing-text.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/typing-text.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/typing-text.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/typing-text.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/typing-text.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/typing-text.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/typing-text.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/typing-text.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/typing-text.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/typing-text.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/typing-text.js"></script>The compiled install writes src/components/zubra/typing-text.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<typing-text text="Bake bread you are proud of."></typing-text>
<script type="module">
import './components/zubra/typing-text.js';
const element = document.querySelector('typing-text');
element.speed = 45;
</script>import './components/zubra/typing-text.js';
const speed = 45;
export function TypingTextExample() {
return (
<typing-text text="Bake bread you are proud of." speed={speed}></typing-text>
);
}<script setup>
import './components/zubra/typing-text.js';
const speed = 45;
</script>
<template>
<typing-text text="Bake bread you are proud of." :speed.prop="speed"></typing-text>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/typing-text.js';
const speed = 45;
</script>
<typing-text text="Bake bread you are proud of." {speed}></typing-text>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/typing-text.js';
@Component({
selector: 'app-typing-text-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<typing-text text="Bake bread you are proud of." [speed]="speed"></typing-text>
`,
})
export class TypingTextExample {
speed = 45;
}API
| Property | Type | Default |
|---|---|---|
text | string | "" |
speed | number | 45 |
delay | number | 200 |
caret | boolean | true |
Size
1.1 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.7 KB.