What is Griffo?
Griffo is a kerning-aware text splitting library that lets you split text into characters, words, and lines for animation — without breaking your typography. Most splitting libraries wrap each character in a<span> and call it done, but that destroys the kerning between character pairs. Griffo compensates for this automatically, maintaining pixel-perfect spacing even when every character is wrapped in its own element.
Quick Links
Quickstart
Get up and running in minutes with vanilla JS, React, or Motion
Installation
Install Griffo with npm, yarn, or pnpm
Core API
Learn the splitText() function API
Key Features
Kerning Compensation
Maintains original character spacing when splitting by chars — no visual jumping
Nested Elements
Preserves
<a>, <em>, <strong> and other inline elements with all attributesLine Detection
Groups words into rendered lines automatically based on layout
Dash Handling
Wraps naturally after em-dashes, en-dashes, hyphens, and slashes
Auto Re-split
Re-splits on container resize for responsive animations
Auto Revert
Restores original HTML after animations complete
Masking
Clip containers for reveal animations
Emoji Support
Handles compound emojis and complex Unicode characters
Accessible
Automatic screen reader support, even with nested links or emphasis
TypeScript
Full type definitions included
Zero Dependencies
7 kB core with no external packages
Library Agnostic
Works with Motion, GSAP, CSS, WAAPI, or any animation code
Entry Points
Griffo provides multiple entry points optimized for different use cases:| Import | Use for | Size |
|---|---|---|
griffo | Vanilla JS or any framework | 7.11 kB |
griffo/react | React with callback/lifecycle control | 8.23 kB |
griffo/motion | Declarative Motion animations | 13.78 kB |
griffo/morph | Standalone MorphText component | 7.95 kB |
Sizes are minified + brotli compressed
Why Griffo?
The Problem
When you wrap each character in a<span> for animation, browsers lose the kerning information between character pairs. This causes text to subtly shift and look awkward:
The Solution
Griffo measures the exact kerning between each character pair before splitting, then applies margin compensation after splitting to restore the original spacing:Next Steps
Install Griffo
Add Griffo to your project with npm, yarn, or pnpmInstallation Guide →
Follow the Quickstart
Learn the basics with vanilla JS, React, or Motion examplesQuickstart →
Explore the API
Dive into the full API documentation for advanced featuresAPI Reference →