Eye Glyph
Any letter with a hole becomes an eye: the pupil follows the pointer, lashes grow on top, and real lids close it when it blinks. Poke one and it winks.
View codeHand-drawn marks that draw themselves on key words when the paragraph shows up: underline, strike, circle or marker.
With your AI
Say it to your AI. It gets the exact code below, not its best guess, and knows where it goes.
Mark the key words of my intro with Kodza Annotated Text.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<p class="kodza-annotate-text">
Copy, paste and <span class="kodza-annotate" data-annotate="underline">ship</span> before lunch.
No <span class="kodza-annotate" data-annotate="strike">webpack config</span>,
<span class="kodza-annotate" data-annotate="circle">zero</span> dependencies,
and a <span class="kodza-annotate" data-annotate="marker">clear conscience</span>.
</p>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Annotated Text
Hand-drawn marks that draw themselves on key words when the paragraph reaches the
screen, one after the other: underline, strike, circle or marker (data-annotate).
Every stroke is a little different, like a real pen. Send a "kodza:replay" event to the
paragraph to draw them again. Everything is tuned with the --kz-annotate-* variables. */
.kodza-annotate-text {
--kz-annotate-color: currentColor;
--kz-annotate-marker: rgba(10, 10, 10, 0.13);
--kz-annotate-width: 2.5px;
--kz-annotate-duration: 0.8s;
--kz-annotate-gap: 0.25s;
}
.kodza-annotate {
position: relative;
display: inline-block;
}
.kodza-annotate__svg {
position: absolute;
inset: -0.2em -0.3em;
width: calc(100% + 0.6em);
height: calc(100% + 0.4em);
overflow: visible;
pointer-events: none;
}
.kodza-annotate[data-annotate="marker"] .kodza-annotate__svg {
z-index: -1;
}
.kodza-annotate-text {
isolation: isolate;
}
.kodza-annotate__svg path {
fill: none;
stroke: var(--kz-annotate-color);
stroke-width: var(--kz-annotate-width);
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 1;
stroke-dashoffset: 1;
}
.kodza-annotate[data-annotate="marker"] path {
stroke: var(--kz-annotate-marker);
stroke-width: 0.95em;
stroke-linecap: butt;
}
.kodza-annotate-text.is-drawn .kodza-annotate__svg path {
stroke-dashoffset: 0;
transition: stroke-dashoffset var(--kz-annotate-duration) cubic-bezier(0.65, 0, 0.35, 1);
transition-delay: calc(var(--i, 0) * (var(--kz-annotate-duration) * 0.6 + var(--kz-annotate-gap)));
}
/* Played again: the marks are first taken back by the pen, all together, then redrawn */
.kodza-annotate-text.is-erasing .kodza-annotate__svg path {
stroke-dashoffset: 1;
transition: stroke-dashoffset 0.38s cubic-bezier(0.65, 0, 0.35, 1);
}
/* Without the script, or with reduced motion: the marks are simply there */
@media (prefers-reduced-motion: reduce) {
.kodza-annotate__svg path {
stroke-dashoffset: 0;
transition: none !important;
}
}
/* kodza-guard 04284701beec — generated by Kodza, do not edit.
Theme guard: keeps a site's own CSS (WordPress themes, Bootstrap, CSS resets…) off this
component. :not(#_) is always true and weighs as much as an id, so these lines win over
theme rules made of classes and tags. Customise the component through its --kz-* variables. */
/* What the browser gives, on everything the component leaves to it */
.kodza-annotate-text:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: revert;
box-sizing: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-height: revert;
color: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-annotate:not(#_) {
box-sizing: revert;
}
.kodza-annotate__svg:not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-annotate-text:not(#_):where(:not([hidden])),
.kodza-annotate__svg:not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-annotate-text:not(#_):where([hidden]),
.kodza-annotate__svg:not(#_):where([hidden]) {
display: none;
}
/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */
.kodza-annotate__svg:not(#_) {
position: absolute;
}
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Annotated Text
// Draws an SVG mark on each [data-annotate] word, at its real size, with a little
// randomness so no two strokes are the same (each mark keeps its own, so a replay or a
// reflow redraws the same stroke). When the paragraph reaches the screen,
// the marks draw themselves in order; played again, they are taken back before being redrawn.
// Redrawn at the right size when the text reflows.
(() => {
const SELECTOR = '.kodza-annotate-text';
const SVG = 'http://www.w3.org/2000/svg';
// A wobble, so the line looks drawn by hand. Each mark draws from its own seed (mulberry32):
// every stroke differs, but the same mark redrawn keeps its shape
const seeds = new WeakMap();
let next = Math.random;
const seeded = (seed) => () => {
seed = (seed + 0x6d2b79f5) | 0;
let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
const wobble = (amount) => (next() - 0.5) * 2 * amount;
const SHAPES = {
underline: (w, h) => {
const y = h - h * 0.12;
return `M ${w * 0.04} ${y + wobble(1.5)} Q ${w * 0.5} ${y + 3 + wobble(2)} ${w * 0.97} ${y - 1 + wobble(1.5)}`;
},
strike: (w, h) => {
const y = h * 0.55;
return `M ${w * 0.03} ${y + 2 + wobble(1)} L ${w * 0.97} ${y - 2 + wobble(1)}`;
},
marker: (w, h) => {
const y = h * 0.58;
return `M ${w * 0.04} ${y + wobble(1)} L ${w * 0.96} ${y + wobble(1)}`;
},
// An ellipse drawn in one go, which overshoots its start like a real pen
circle: (w, h) => {
const cx = w / 2, cy = h / 2, rx = w / 2 + 2, ry = h / 2 + 1;
const points = [];
for (let a = -0.35; a <= Math.PI * 2 + 0.25; a += 0.18) {
const r = 1 + wobble(0.035);
points.push(`${(cx + Math.cos(a) * rx * r).toFixed(1)} ${(cy + Math.sin(a) * ry * r - a * 0.6).toFixed(1)}`);
}
return `M ${points.join(' L ')}`;
},
};
// k: screen pixels per CSS pixel (a parent scaled with a transform must not change the stroke)
function draw(mark, k = 1) {
const shape = SHAPES[mark.dataset.annotate] || SHAPES.underline;
let svg = mark.querySelector('.kodza-annotate__svg');
if (!svg) {
svg = document.createElementNS(SVG, 'svg');
svg.setAttribute('class', 'kodza-annotate__svg');
svg.setAttribute('aria-hidden', 'true');
svg.append(document.createElementNS(SVG, 'path'));
mark.append(svg);
}
const box = svg.getBoundingClientRect();
const width = box.width / k;
const height = box.height / k;
if (!width || !height) return;
svg.setAttribute('viewBox', `0 0 ${width.toFixed(1)} ${height.toFixed(1)}`);
const path = svg.firstChild;
if (!seeds.has(mark)) seeds.set(mark, (Math.random() * 2 ** 32) >>> 0);
next = seeded(seeds.get(mark));
path.setAttribute('d', shape(width, height));
path.setAttribute('pathLength', '1');
}
// One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
function mount(root, signal) {
const marks = [...root.querySelectorAll('[data-annotate]')];
marks.forEach((mark, i) => mark.style.setProperty('--i', i));
const render = () => {
const k = root.getBoundingClientRect().width / root.offsetWidth || 1;
marks.forEach((mark) => draw(mark, k));
};
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
let wait = 0;
const start = () => {
root.classList.remove('is-drawn', 'is-erasing');
render();
void root.offsetWidth; // start from an empty page
root.classList.add('is-drawn');
};
// Played again: the pen takes the marks back first, rather than wiping them at once
const play = () => {
clearTimeout(wait);
if (!root.classList.contains('is-drawn') || reduceMotion) return start();
root.classList.add('is-erasing');
wait = setTimeout(start, 420);
};
// Marks are measured on the real font: drawn once it has loaded, redrawn on resize after that
let fontsReady = false;
document.fonts.ready.then(() => {
if (signal.aborted) return;
fontsReady = true;
render();
const observer = new IntersectionObserver((entries) => {
if (!entries[0].isIntersecting) return;
observer.disconnect();
play();
}, { threshold: 0.6 });
observer.observe(root);
signal.addEventListener('abort', () => observer.disconnect());
});
let width = 0;
const resize = new ResizeObserver(([entry]) => {
if (Math.abs(entry.contentRect.width - width) < 1) return;
width = entry.contentRect.width;
if (fontsReady) render();
});
resize.observe(root);
signal.addEventListener('abort', () => {
resize.disconnect();
clearTimeout(wait);
});
root.addEventListener('kodza:replay', play, { signal });
}
// Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
// event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
// markup back. For themes and apps that swap content without a page load.
const instances = new WeakMap();
const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
const init = (scope) => find(scope).forEach((root) => {
if (root.classList.contains('is-ready')) return; // already running, maybe from another copy of this script
const controller = new AbortController();
instances.set(root, { controller, html: root.innerHTML, attrs: [...root.attributes].map((a) => [a.name, a.value]) });
mount(root, controller.signal);
root.classList.add('is-ready');
});
const destroy = (scope) => find(scope).forEach((root) => {
const instance = instances.get(root);
if (!instance) return;
instances.delete(root);
instance.controller.abort();
[...root.attributes].forEach((a) => root.removeAttribute(a.name));
instance.attrs.forEach(([name, value]) => root.setAttribute(name, value));
root.innerHTML = instance.html;
});
document.addEventListener('kodza:init', (event) => init(event.detail?.root));
document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
init();
// Loaded in <head>, the script runs before the markup exists: once more when it is parsed
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
'use client';
// Kodza — Annotated Text, for React. From https://kodza.dev/components/text-highlight/
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Next to this file: text-highlight.css and text-highlight.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './text-highlight.css';
export type AnnotatedTextProps = Omit<ComponentPropsWithoutRef<'p'>, "children" | "vars"> & {
/** Settings, as CSS variables on the root */
vars?: {
/** default: currentColor */
"--kz-annotate-color"?: string | number;
/** default: rgba(10, 10, 10, 0.13) */
"--kz-annotate-marker"?: string | number;
/** default: 2.5px */
"--kz-annotate-width"?: string | number;
/** default: 0.8s */
"--kz-annotate-duration"?: string | number;
/** default: 0.25s */
"--kz-annotate-gap"?: string | number;
};
className?: string;
};
export function AnnotatedText({ vars, className, style, ...rest }: AnnotatedTextProps) {
const ref = useRef<ComponentRef<'p'>>(null);
const classes = ["kodza-annotate-text", className].filter(Boolean).join(' ');
// Everything the markup is made of: when it changes, React gets a fresh element (see the top)
const key = JSON.stringify([classes, vars, style, rest]);
// Starts the script on this element once React has rendered it, stops it when it goes
useEffect(() => {
const root = ref.current;
let live = true;
// @ts-ignore: a plain script, no types to find
import('./text-highlight.js').then(() => {
if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
});
return () => {
live = false;
document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
};
}, [key]);
return (
<p key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}> Copy, paste and <span className="kodza-annotate" data-annotate="underline">ship</span> before lunch. No <span className="kodza-annotate" data-annotate="strike">webpack config</span>, <span className="kodza-annotate" data-annotate="circle">zero</span> dependencies, and a <span className="kodza-annotate" data-annotate="marker">clear conscience</span>. </p>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.