SVG Text Draw
An SVG word whose letter outlines draw themselves, then fill with colour: on a loop, just once, or at the moment you choose.
Updated
This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. SVG has 30 effects, including 3 free. Explore the category →
3 usage examples



How it works
The word is a <text> element (class .txd-text) centred in a 220×80-unit SVG, at size 48 and weight 800. It gets an outline (--txd-line, width 1.5) cut into 400-unit dashes; each letter has its own outline and the dash restarts at the beginning of each, so all the letters draw at the same time.
The txdDraw animation lasts --txd-speed (3 s): from 0 to 50%, the dash offset goes from 400 to 0 and the outline draws over still-empty letters; from 50 to 70%, the fill colour (--txd-fill) comes in; the word then stays filled until the end of the cycle. By default the cycle loops and restarts from an empty word; --txd-repeat: 1 plays it once and leaves the word filled, --txd-play: paused makes it wait.
The drawing depends on the font: the code asks for Inter, then the system font. It downloads no font; if Inter is not installed, the system font is what gets drawn. The word is centred (x="110", text-anchor="middle"), so it stays in the middle when you change it.
Accessibility
- Announced text: the SVG carries
role="img"and a<title>repeating the word; that is what screen readers read. Change it together with the text. - Page heading: placed in an
<h1>or<h2>, the SVG gives the heading its name; the word also stays present as text in the HTML. - Reduced motion: with
prefers-reduced-motion: reduce, the word shows straight away with outline and fill, even when set to wait (measured in all three engines: 0 running animations). - Contrast: the
#6366f1indigo reaches 4.4:1 on the shipped background; for a word over a photo, keep a fairly plain area behind the letters.
Browser compatibility
Pure CSS. Reduced motion needs Chrome 74, Firefox 63 and Safari 10.1. Measured in Chromium 151, Firefox 153 and WebKit 26.5: 0 errors, a single animation per word, two independent copies, nothing overflowing at 390 px. The exact drawing varies with the font installed on the device.
Without CSS animations, the word shows filled with its outline. Without the requested font, it draws in the system's fallback font.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0605-root">
<svg class="txd-svg" viewBox="0 0 220 80" role="img">
<title>SVG</title>
<text class="txd-text" x="110" y="58" text-anchor="middle">SVG</text>
</svg>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
The word (<text> and <title>) |
SVG | Change both together; widen the viewBox (and x, its half) for a longer word. |
--txd-repeat |
infinite |
1: the word draws once and stays filled. |
--txd-play |
running |
paused: nothing shows until set back to running (for instance when the word becomes visible). |
--txd-speed |
3s |
Cycle length: half for the outline, a fifth for the fill. |
--txd-line and --txd-fill |
#6366f1 and #6366f1 |
Colours of the outline and of the final fill. |
--txd-font, --txd-weight, --txd-stroke |
Inter then system font, 800, 1.5 |
Font, weight and outline width; a thin font calls for a thinner outline. |
--txd-width, --txd-bg, --txd-min-h |
220px, #0a0a0f, 300px |
Drawing width (the height follows the viewBox), frame background and minimum height. |
FAQ
--txd-font.viewBox (for example 0 0 420 80), set x to the middle (210) and raise --txd-width to keep the same on-screen size.