# Ink Like

> Like button whose heart fills with ink, a small wave riding the surface, and drains when the like is taken back. The count rolls digit by digit with carries (999 → 1,000) and rolls back if the request fails.

Buttons · button, like, heart, counter, toggle · HTML, CSS, vanilla JS · no dependencies · updated 2026-10-26
Demo: https://kodza.dev/components/ink-like/

## Files

The code below, served as files: byte for byte what the Kodza site copies (the CSS includes its theme guard).

- [`kodza-ink-like.css`](https://kodza.dev/registry/ink-like/kodza-ink-like.css) · 8.2 KB
- [`kodza-ink-like.js`](https://kodza.dev/registry/ink-like/kodza-ink-like.js) · 13.2 KB
- [`kodza-ink-like.html`](https://kodza.dev/registry/ink-like/kodza-ink-like.html) · 1.5 KB · the markup, to adapt and paste into your page

**Can you run shell commands? Download the CSS and the JS, don't retype them.** Retyping costs thousands of tokens and can drop or change lines of the CSS. Put the files where your stack expects them (Use it says where: change the `-o` paths):

```bash
curl -fsSL --create-dirs -o kodza/kodza-ink-like.css https://kodza.dev/registry/ink-like/kodza-ink-like.css
curl -fsSL --create-dirs -o kodza/kodza-ink-like.js https://kodza.dev/registry/ink-like/kodza-ink-like.js
```

Then load the files from your page as Use it shows, instead of pasting the content. The HTML is the part you adapt (text, links, modifiers): paste it from the Code section. Copy the CSS and the JS from the Code section only if you can't run commands, exactly as they are. (Windows PowerShell: `curl.exe`.)

## API

- Root: `.kodza-ink-like`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-ink-like-fg: #0a0a0a`
  - `--kz-ink-like-bg: rgba(10, 10, 10, 0.06)`
  - `--kz-ink-like-bg-hover: rgba(10, 10, 10, 0.1)`
  - `--kz-ink-like-height: 52px`
  - `--kz-ink-like-pad-x: 20px`
  - `--kz-ink-like-icon: 22px`
  - `--kz-ink-like-ease: cubic-bezier(0.22, 1, 0.36, 1)`
- Modifiers: `.kodza-ink-like--bare`
- Attributes:
  - `data-count` (e.g. `999`, `128`)
  - `data-say-liked`
  - `data-say-refused`
  - `data-say-unliked`
- Events: `kodza:like` (bubbling, from the root)
- Lifecycle: `kodza:init` / `kodza:destroy` on `document`, with `{ detail: { root } }` to target a container.

## Keyboard

What each key does, by where the focus is. Keep it working when you adapt the HTML: same elements, same classes.

- On the button (focus in `.kodza-ink-like`):
  - `Enter` / `Space`: Likes, or takes the like back

## Dark mode

The values Kodza uses on a dark background (`#0a0a0a`). For a page that follows the system theme, add them after the component's CSS:

```css
@media (prefers-color-scheme: dark) {
  .kodza-ink-like {
    --kz-ink-like-fg: #f2f2f0;
  }

  .kodza-ink-like:not(.kodza-ink-like--bare) {
    --kz-ink-like-bg: rgba(255, 255, 255, 0.08);
    --kz-ink-like-bg-hover: rgba(255, 255, 255, 0.13);
  }
}
```

A site with its own theme switch puts the same rules under its dark selector instead (`[data-theme="dark"] .kodza-ink-like { … }`); a single dark section, under that section's class.

## Use it

### Plain HTML page

- CSS: `kodza/kodza-ink-like.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-ink-like.css">`. Without a shell, paste it in a `<style>` in `<head>` instead. It only touches `kodza-` classes.
- HTML: where the component goes. Paste it as many times as you need: instances never interfere.
- JS: `kodza/kodza-ink-like.js`, loaded with `<script src="kodza/kodza-ink-like.js" defer></script>` in `<head>`. Without a shell, paste it in a `<script>` before `</body>` (or in `<head>`: it waits for the page). One copy per page, whatever the number of instances.
- Restyle with the `--kz-…` variables, set on the component's root element itself (the root declares its own defaults, so a value on an ancestor is ignored), and with the modifiers / attributes listed under API.
- Font: it takes the page's own. The Kodza look is Geist: `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`.
- Content added later (AJAX navigation, a SPA route, a builder preview): start it with `document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: container } }))`; before removing it, the same call with `'kodza:destroy'` stops it and puts the original markup back.

### Claude artifact (claude.ai)

- Paste the CSS in a `<style>` and the JS in a `<script>` at the end, in the artifact itself: it loads stylesheets only from Google Fonts and scripts only from a few CDNs, so no `<link>` or `<script src>` to Kodza.
- Writing the artifact file with a shell? Insert the downloaded files (Files) with a command instead of retyping them: a line `KODZA-CSS` alone inside the `<style>`, `KODZA-JS` inside the `<script>`, then `sed -e '/^KODZA-CSS$/{r kodza/kodza-ink-like.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-ink-like.js' -e 'd' -e '}' page.html > artifact.html`.
- Font: load Geist from Google Fonts (allowed): `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`.
- Dark mode: the viewer sets `data-theme="dark"` or `"light"` on `<html>`, or nothing when it follows the system. Write the Dark mode rules twice: inside `@media (prefers-color-scheme: dark)` with `:root:not([data-theme="light"])` in front of each selector, and with `:root[data-theme="dark"]` in front of each selector.

### WordPress

- HTML: a **Custom HTML** block (or a pattern / template part). WordPress keeps this markup as it is only for users allowed to post unfiltered HTML (Administrators; Super Admins on multisite): for anyone else it strips tags such as `<svg>`, `<input>` or `<dialog>`, so add it from the theme (a pattern or template part) instead.
- This one is inline (it flows like a word): pasted alone, many themes leave it at the edge of the page (block themes, and classic ones like Twenty Twenty-One or Blocksy), so put the Custom HTML block inside a **Group** block to line it up with the text.
- CSS and JS: the downloaded files go in the theme, under `wp-content/themes/<your-theme>/kodza/` (the child theme if there is one), enqueued from its functions.php (or a code-snippets plugin):
  ```php
  add_action('wp_enqueue_scripts', function () {
    $dir = get_stylesheet_directory() . '/kodza/';
    $uri = get_stylesheet_directory_uri() . '/kodza/';
    wp_enqueue_style('kodza-ink-like', $uri . 'kodza-ink-like.css', [], filemtime($dir . 'kodza-ink-like.css'));
    wp_enqueue_script('kodza-ink-like', $uri . 'kodza-ink-like.js', [], filemtime($dir . 'kodza-ink-like.js'), true);
  });
  ```
  Scoped to `kodza-` classes, the CSS never touches the theme. One copy of the JS, whatever the number of blocks.
- No access to the theme files? The CSS can also go, as it is, in **Appearance → Customize → Additional CSS** (classic theme) or **Styles → Additional CSS** in the Site Editor (block theme).
- Theme with AJAX page transitions: fire `kodza:init` on the new content after each swap (and `kodza:destroy` on the old one).
- Performance plugin (WP Rocket, LiteSpeed Cache, Perfmatters…) with **Delay JavaScript execution** turned on: add `kodza` to the scripts it must not delay. Otherwise the component waits for the visitor's first scroll, tap or mouse move, and that first click can be lost.
- Colours: it takes the colour of the text around it (or keeps its own monochrome): nothing to point at the theme.
- WordPress turns straight quotes and `--` into typographic ones in the text of a Custom HTML block (not inside `<code>` or `<pre>`).

#### With Elementor

- HTML: an **HTML** widget (Elementor shows it to administrators only). It keeps the code exactly as pasted, straight quotes included.
- CSS and JS: as above. Elementor's Site Settings → Theme Style styles every button, field, link and image of the page, components included; the theme guard at the end of the CSS keeps the component's buttons, fields and link colours as they are.
- The Elementor editor redraws each widget after the page has loaded: without the script below, the component stays still in the editor preview (the published page works). Add it once per site, in the footer like the component's script (`kodza/elementor-editor.js`, or a code-snippets plugin):

```js
// Kodza in the Elementor editor: the editor redraws each HTML widget after the page has loaded.
// Start Kodza in what it draws, stop it in what it replaces or removes. Once per site.
window.addEventListener('elementor/frontend/init', () => {
  if (!elementorFrontend.isEditMode()) return;
  class KodzaWidget extends elementorModules.frontend.handlers.Base {
    onInit() {
      super.onInit();
      this.kodza = [...this.$element[0].children];
      document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: this.$element[0] } }));
    }
    onDestroy() {
      super.onDestroy();
      this.kodza.forEach((root) => document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } })));
    }
  }
  elementorFrontend.elementsHandler.attachHandler('html', KodzaWidget);
});
```

- No child theme: everything can go in the HTML widget instead, `<style>` with the CSS, the HTML, then `<script>` with the JS. It works on the page and in the editor without the script above.

### Shopify

- Files: `assets/kodza-ink-like.css` and `assets/kodza-ink-like.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-ink-like.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-ink-like.js' | asset_url }}" defer></script>`, then the HTML.
- The theme editor re-renders sections: restart them with
  `document.addEventListener('shopify:section:load', (e) => document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: e.target } })));`
  and the same with `shopify:section:unload` → `kodza:destroy`.

### React / Next.js

- Files, side by side (e.g. in `components/kodza/`): `InkLike.tsx` (below), the CSS block under Code saved as `ink-like.css` and the JS block as `ink-like.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { InkLike } from '@/components/kodza/InkLike';` then `<InkLike>999</InkLike>`. Props: `variant` ("bare", or several in an array), `count` (`data-count`: "999", "128"), `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-ink-like-fg': … }}`), `children` (the text, plain), `onLike` (the `kodza:like` event), `className`, `style` and the other props of its `<button>` (`onClick`, `aria-…`).
- Next.js App Router: it is a Client Component already (`'use client'`). Pages Router: Next.js takes global CSS only in `pages/_app`, so move the `import './ink-like.css'` line there.
- Safe under StrictMode, client-side navigation and prop changes: when a prop changes, the `key` gives React a fresh element, `kodza:destroy` stops the script on the old one and `kodza:init` starts it on the new one.
- Built from your data (tabs, rows, options)? Add what the markup is made of to the `key`, as plain values (ids, text, numbers). What the visitor changes (the open tab, the sort, what they type) is the script's: follow it with `onClick` or `onInput` on the root, and change it from your code as a visitor would (click the tab; set the field's value, then dispatch a bubbling `input` event). Fields stay uncontrolled (`defaultValue`, `name`).

```tsx
'use client';
// Kodza — Ink Like, for React. From https://kodza.dev/components/ink-like/
// 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: ink-like.css and ink-like.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.
// Built from your data (tabs, rows, options)? Put what the markup is made of in the key, as plain
// values (ids, text, numbers): a change starts the script again on fresh markup. What the visitor
// changes (the open tab, the sort, what they type) is the script's: keep it out of the key, follow
// it with onClick or onInput on the root, and change it from your code as a visitor would (click
// the tab; set the field's value, then dispatch a bubbling input event).
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './ink-like.css';

type Variant = "bare";

export type InkLikeProps = Omit<ComponentPropsWithoutRef<'button'>, "children" | "variant" | "vars" | "count" | "onLike"> & {
  /** Modifier class(es): .kodza-ink-like--bare */
  variant?: Variant | Variant[];
  /** data-count on the root (default: 999) */
  count?: "999" | "128";
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #0a0a0a */
    "--kz-ink-like-fg"?: string | number;
    /** default: rgba(10, 10, 10, 0.06) */
    "--kz-ink-like-bg"?: string | number;
    /** default: rgba(10, 10, 10, 0.1) */
    "--kz-ink-like-bg-hover"?: string | number;
    /** default: 52px */
    "--kz-ink-like-height"?: string | number;
    /** default: 20px */
    "--kz-ink-like-pad-x"?: string | number;
    /** default: 22px */
    "--kz-ink-like-icon"?: string | number;
    /** default: cubic-bezier(0.22, 1, 0.36, 1) */
    "--kz-ink-like-ease"?: string | number;
  };
  /** The text, plain: the script reads it and rebuilds the markup around it */
  children?: string;
  /** "kodza:like", fired by the script (bubbles from the root) */
  onLike?: (event: CustomEvent) => void;
  className?: string;
};

export function InkLike({ variant, count = "999", vars, children = "999", onLike, className, style, ...rest }: InkLikeProps) {
  const ref = useRef<ComponentRef<'button'>>(null);
  const classes = ["kodza-ink-like", ...([] as string[]).concat(variant ?? []).map((v) => `kodza-ink-like--${v}`), 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, count, vars, children, 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('./ink-like.js').then(() => {
      if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
    });
    return () => {
      live = false;
      document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
    };
  }, [key]);

  useEffect(() => {
    const root = ref.current;
    if (!root || !onLike) return;
    const listener = (event: Event) => onLike(event as CustomEvent);
    root.addEventListener("kodza:like", listener);
    return () => root.removeEventListener("kodza:like", listener);
  }, [onLike, key]);

  return (
    <button type="button" aria-pressed="false" aria-label="Like, 999 likes" key={key} {...rest} className={classes} data-count={count} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <svg className="kodza-ink-like__icon" viewBox="0 0 24 24" aria-hidden="true">
        <g className="kodza-ink-like__ink">
          <g className="kodza-ink-like__level">
            <g className="kodza-ink-like__surface">
              <path className="kodza-ink-like__wave" d="M-48 2q6-2.4 12 0t12 0t12 0t12 0t12 0t12 0t12 0t12 0V40H-48z" />
            </g>
          </g>
        </g>
        <path className="kodza-ink-like__shape" d="M12 20.5C10.5 19.3 2.5 13.8 2.5 8.6 2.5 5.8 4.6 3.8 7.2 3.8 9.2 3.8 10.9 5 12 6.7 13.1 5 14.8 3.8 16.8 3.8 19.4 3.8 21.5 5.8 21.5 8.6 21.5 13.8 13.5 19.3 12 20.5Z" />
      </svg>
      {' '}
      <span className="kodza-ink-like__count" aria-hidden="true">{children}</span>
    </button>
  );
}
```

## Code

```html
<button class="kodza-ink-like" type="button" aria-pressed="false" aria-label="Like, 999 likes" data-count="999">
  <svg class="kodza-ink-like__icon" viewBox="0 0 24 24" aria-hidden="true">
    <g class="kodza-ink-like__ink">
      <g class="kodza-ink-like__level">
        <g class="kodza-ink-like__surface">
          <path class="kodza-ink-like__wave" d="M-48 2q6-2.4 12 0t12 0t12 0t12 0t12 0t12 0t12 0t12 0V40H-48z" />
        </g>
      </g>
    </g>
    <path class="kodza-ink-like__shape" d="M12 20.5C10.5 19.3 2.5 13.8 2.5 8.6 2.5 5.8 4.6 3.8 7.2 3.8 9.2 3.8 10.9 5 12 6.7 13.1 5 14.8 3.8 16.8 3.8 19.4 3.8 21.5 5.8 21.5 8.6 21.5 13.8 13.5 19.3 12 20.5Z" />
  </svg>
  <span class="kodza-ink-like__count" aria-hidden="true">999</span>
</button>

<button class="kodza-ink-like kodza-ink-like--bare" type="button" aria-pressed="true" aria-label="Like, 128 likes" data-count="128">
  <svg class="kodza-ink-like__icon" viewBox="0 0 24 24" aria-hidden="true">
    <g class="kodza-ink-like__ink">
      <g class="kodza-ink-like__level">
        <g class="kodza-ink-like__surface">
          <path class="kodza-ink-like__wave" d="M-48 2q6-2.4 12 0t12 0t12 0t12 0t12 0t12 0t12 0t12 0V40H-48z" />
        </g>
      </g>
    </g>
    <path class="kodza-ink-like__shape" d="M12 20.5C10.5 19.3 2.5 13.8 2.5 8.6 2.5 5.8 4.6 3.8 7.2 3.8 9.2 3.8 10.9 5 12 6.7 13.1 5 14.8 3.8 16.8 3.8 19.4 3.8 21.5 5.8 21.5 8.6 21.5 13.8 13.5 19.3 12 20.5Z" />
  </svg>
  <span class="kodza-ink-like__count" aria-hidden="true">128</span>
</button>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Ink Like
   A like button whose heart fills with ink. Liked, the ink rises with a small wave riding its
   surface; taken back, it drains through the tip. The count rolls digit by digit, carries
   included (999 → 1,000). The state lives in aria-pressed and the total in data-count: set them
   from your code and the button follows. Under the pointer, a drop of ink waits in the tip.
   From your code: listen to "kodza:like" and pass your request to event.detail.wait(promise);
   if it fails, the like rolls back, and if it resolves to a number, the count rolls to it.
   Everything is tuned with the --kz-ink-like-* variables. */
.kodza-ink-like {
  --kz-ink-like-fg: #0a0a0a;
  --kz-ink-like-bg: rgba(10, 10, 10, 0.06);
  --kz-ink-like-bg-hover: rgba(10, 10, 10, 0.1);
  --kz-ink-like-height: 52px;
  --kz-ink-like-pad-x: 20px;
  --kz-ink-like-icon: 22px;
  --kz-ink-like-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  height: var(--kz-ink-like-height);
  margin: 0;
  padding: 0 calc(var(--kz-ink-like-pad-x) + 2px) 0 var(--kz-ink-like-pad-x);
  border: 0;
  border-radius: 999px;
  background: var(--kz-ink-like-bg);
  color: var(--kz-ink-like-fg);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease;
}

.kodza-ink-like:focus-visible {
  outline: 2px solid var(--kz-ink-like-fg);
  outline-offset: 3px;
}

/* Bare: the heart and its count alone, for a row of actions under a post */
.kodza-ink-like--bare {
  --kz-ink-like-bg: transparent;
  --kz-ink-like-bg-hover: transparent;
  --kz-ink-like-pad-x: 8px;
}

/* The heart: its outline, and the ink cut to the same shape by the script */
.kodza-ink-like__icon {
  display: block;
  flex: none;
  width: var(--kz-ink-like-icon);
  height: var(--kz-ink-like-icon);
  overflow: hidden;
  transition: transform 0.25s var(--kz-ink-like-ease);
}

.kodza-ink-like:active .kodza-ink-like__icon {
  transform: scale(0.86);
}

.kodza-ink-like__shape {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.kodza-ink-like:not(.is-ready) .kodza-ink-like__ink {
  visibility: hidden;
}

/* The level: just under the tip when empty, just over the top when liked, so the whole rise
   shows. It rises fast and settles in the lobes, and drains faster, gathering speed as it goes */
.kodza-ink-like__level,
.kodza-ink-like__surface,
.kodza-ink-like__wave {
  transform-box: view-box;
}

.kodza-ink-like__level {
  transform: translateY(19px);
  transition: transform 420ms cubic-bezier(0.6, 0, 0.8, 0.4);
}

.kodza-ink-like[aria-pressed="true"] .kodza-ink-like__level {
  transform: translateY(1px);
  transition-duration: 760ms;
  transition-timing-function: cubic-bezier(0.3, 0.7, 0.3, 1);
}

/* The surface: calm at rest, stirred by the script while the ink moves */
.kodza-ink-like__surface {
  transform: scaleY(0.7);
  transform-origin: 12px 2px;
}

.kodza-ink-like__wave {
  fill: currentColor;
  animation: kodza-ink-like-wave 1.1s linear infinite paused;
}

.kodza-ink-like.is-flowing .kodza-ink-like__wave {
  animation-play-state: running;
}

@keyframes kodza-ink-like-wave {
  to {
    transform: translateX(24px);
  }
}

@media (hover: hover) {
  .kodza-ink-like:hover {
    background: var(--kz-ink-like-bg-hover);
  }

  /* A drop of ink waits in the tip, until the click */
  .kodza-ink-like:not(.is-spent):not([aria-pressed="true"]):hover .kodza-ink-like__level {
    transform: translateY(16px);
    transition-duration: 380ms;
    transition-timing-function: var(--kz-ink-like-ease);
  }

  .kodza-ink-like:not(.is-spent):hover .kodza-ink-like__wave {
    animation-play-state: running;
  }
}

/* The count: one cell per character, the old digit leaving as the new one comes in */
.kodza-ink-like__count {
  display: inline-flex;
  height: 1.25em;
  line-height: 1.25em;
  font-variant-numeric: tabular-nums;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}

.kodza-ink-like__digit {
  position: relative;
  display: block;
  height: 1.25em;
  overflow: hidden;
}

.kodza-ink-like__digit > span {
  display: block;
}

.kodza-ink-like__digit > span + span {
  position: absolute;
  top: 0;
  left: 0;
}

/* What a screen reader hears after a click */
.kodza-ink-like__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .kodza-ink-like,
  .kodza-ink-like__icon,
  .kodza-ink-like__level {
    transition: none;
  }

  .kodza-ink-like__wave {
    animation: none;
  }
}

/* kodza-guard de1c4773ddac — 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, where the component sets it only in some states: at the lowest weight, so its own rules below put it back */

:where(.kodza-ink-like):not(#_) {
  outline: revert;
  outline-offset: revert;
}

/* What the browser gives, on everything the component leaves to it */

.kodza-ink-like:not(#_) {
  text-decoration: revert;
  list-style: revert;
  box-shadow: revert;
  appearance: revert;
  max-height: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  min-height: revert;
}

.kodza-ink-like__icon:not(#_) {
  border: revert;
  margin: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: 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-ink-like__ink:not(#_),
.kodza-ink-like__level:not(#_),
.kodza-ink-like__surface:not(#_),
.kodza-ink-like__wave:not(#_),
.kodza-ink-like__shape:not(#_),
.kodza-ink-like__count:not(#_),
.kodza-ink-like__digit:not(#_),
.kodza-ink-like__digit span:where(:not([class*="kodza-"])):not(#_) {
  box-sizing: revert;
}

/* 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-ink-like:not(#_) {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  height: var(--kz-ink-like-height);
  margin: 0;
  padding: 0 calc(var(--kz-ink-like-pad-x) + 2px) 0 var(--kz-ink-like-pad-x);
  border: 0;
  border-radius: 999px;
  background: var(--kz-ink-like-bg);
  color: var(--kz-ink-like-fg);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease;
}

.kodza-ink-like:focus-visible:not(#_) {
  outline: 2px solid var(--kz-ink-like-fg);
  outline-offset: 3px;
}

.kodza-ink-like__icon:not(#_) {
  display: block;
  transition: transform 0.25s var(--kz-ink-like-ease);
}

@media (hover: hover) {
  .kodza-ink-like:hover:not(#_) {
    background: var(--kz-ink-like-bg-hover);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-ink-like:not(#_) {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-ink-like__icon:not(#_) {
    transition: none;
  }
}
```

```js
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Ink Like
// A like button whose heart fills with ink: it rises with a small wave riding its surface and
// drains through the tip when the like is taken back; a click halfway turns it round where it
// is. The count rolls digit by digit 380 ms later, carries included (999 → 1,000). The state is
// aria-pressed and the total data-count: change them from your code and the button follows.
// "kodza:like" bubbles from the button and can be cancelled: pass your request to
// event.detail.wait(promise); if it rejects the like rolls back, if it resolves to a number (or
// { count }) the count rolls to it. data-say-liked, data-say-unliked and data-say-refused set
// what a screen reader hears.
(() => {
  const SELECTOR = '.kodza-ink-like';
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  const ease = 'cubic-bezier(0.22, 1, 0.36, 1)';
  const LAG_UP = 380;
  const LAG_DOWN = 120;
  const format = (n) => new Intl.NumberFormat(document.documentElement.lang || undefined).format(n);
  let made = 0;

  // One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
  function mount(root, signal) {
    const svg = root.querySelector('.kodza-ink-like__icon');
    const ink = root.querySelector('.kodza-ink-like__ink');
    const surface = root.querySelector('.kodza-ink-like__surface');
    const count = root.querySelector('.kodza-ink-like__count');
    if (!svg || !ink) return;

    // The ink is cut to the heart: a clip path made of the outline, with an id of its own
    const ns = 'http://www.w3.org/2000/svg';
    const defs = document.createElementNS(ns, 'defs');
    const clip = document.createElementNS(ns, 'clipPath');
    clip.id = `kodza-ink-like-${Math.random().toString(36).slice(2, 8)}-${++made}`;
    svg.querySelectorAll('.kodza-ink-like__shape').forEach((shape) => {
      const copy = shape.cloneNode(true);
      copy.removeAttribute('class');
      clip.append(copy);
    });
    defs.append(clip);
    svg.prepend(defs);
    ink.setAttribute('clip-path', `url(#${clip.id})`);

    const countOf = () => Math.max(0, parseInt(root.dataset.count ?? count?.textContent.replace(/\D/g, ''), 10) || 0);
    let liked = root.getAttribute('aria-pressed') === 'true';
    let total = countOf();
    let shown = total;

    const label = (n) => {
      const text = root.getAttribute('aria-label');
      if (!text) return;
      root.setAttribute('aria-label', text.replace(/\d(?:[\d.,  ]*\d)?(\s+likes?\b)?/, (m, word) => format(n) + (word ? word.replace(/likes?/, n === 1 ? 'like' : 'likes') : '')));
    };

    // The spoken status sits right after the button, and leaves with it
    const status = Object.assign(document.createElement('span'), { className: 'kodza-ink-like__sr' });
    status.setAttribute('role', 'status');
    root.after(status);
    const words = {
      liked: root.dataset.sayLiked || 'Liked',
      unliked: root.dataset.sayUnliked || 'Like removed',
      refused: root.dataset.sayRefused || 'Not saved. Try again.',
    };
    let sayTimer = 0;
    const say = (message) => {
      status.textContent = '';
      clearTimeout(sayTimer);
      sayTimer = setTimeout(() => { status.textContent = message; }, 60);
    };

    // The count: one cell per character, aligned on the right. A digit that changes rolls: up and
    // units first when the count grows, down and from the left when it shrinks (the same roll
    // played backwards). A digit that appears or goes rolls, and opens or closes its room, along
    // with the first digit that turns, so the count moves in one gesture. Taken back halfway, the
    // roll plays backwards from where it is
    const paint = (n) => {
      if (!count) return;
      count.replaceChildren(...[...format(n)].map((ch) => {
        const cell = Object.assign(document.createElement('span'), { className: 'kodza-ink-like__digit' });
        cell.append(Object.assign(document.createElement('span'), { textContent: ch }));
        return cell;
      }));
    };
    let run = null;
    const settle = (current) => {
      Promise.all(current.anims.map((a) => a.finished)).then(() => {
        if (run !== current) return;
        run = null;
        paint(current.to);
      }, () => {});
    };
    const draw = (from, to) => {
      const a = format(from);
      const b = format(to);
      const n = Math.max(a.length, b.length);
      const was = a.padStart(n);
      const now = b.padStart(n);
      const k = to > from ? 1 : -1;
      const delay = (i) => (k > 0 ? n - 1 - i : i) * 55;
      const anims = [];
      const rooms = [];
      const turns = [...now].map((ch, i) => (ch !== was[i] && ch.trim() && was[i].trim() ? delay(i) : Infinity));
      const start = Math.min(...turns);
      count.textContent = '';
      for (let i = 0; i < n; i++) {
        const cell = Object.assign(document.createElement('span'), { className: 'kodza-ink-like__digit' });
        const next = Object.assign(document.createElement('span'), { textContent: now[i].trim() });
        cell.append(next);
        count.append(cell);
        if (was[i] === now[i]) continue;
        const old = Object.assign(document.createElement('span'), { textContent: was[i].trim() });
        cell.append(old);
        const timing = { duration: 480, delay: turns[i] === Infinity && start !== Infinity ? start : delay(i), easing: ease, fill: 'both' };
        anims.push(
          next.animate([{ transform: `translateY(${100 * k}%)` }, { transform: 'none' }], timing),
          old.animate([{ transform: 'none' }, { transform: `translateY(${-100 * k}%)` }], timing),
        );
        // Widths from the layout, to the subpixel (a transform on a parent leaves them alone): the
        // last frame is exactly the count painted after it
        const wide = parseFloat(getComputedStyle(next).width);
        const narrow = parseFloat(getComputedStyle(old).width);
        if (wide !== narrow) rooms.push([cell, narrow, wide]);
      }
      const timing = { duration: 480, delay: start === Infinity ? 0 : start, easing: ease, fill: 'both' };
      rooms.forEach(([cell, narrow, wide]) => {
        anims.push(cell.animate([{ width: `${narrow}px` }, { width: `${wide}px` }], timing));
      });
      run = { from, to, anims };
      settle(run);
    };
    const roll = (to) => {
      if (to === shown || !count) return;
      if (run && run.from === to) {
        run.anims.forEach((a) => a.reverse());
        run = { from: run.to, to, anims: run.anims };
        settle(run);
      } else {
        run?.anims.forEach((a) => a.cancel());
        run = null;
        if (reduceMotion) paint(to);
        else draw(shown, to);
      }
      shown = to;
    };
    let lag = 0;
    const later = (ms) => {
      clearTimeout(lag);
      lag = setTimeout(() => {
        lag = 0;
        roll(total);
      }, reduceMotion ? 0 : ms);
    };

    // The surface sloshes while the ink moves: it tilts against the flow, overshoots, settles
    let slosh = null;
    let flowTimer = 0;
    const flow = (up) => {
      if (reduceMotion || !surface) return;
      root.classList.add('is-flowing');
      clearTimeout(flowTimer);
      flowTimer = setTimeout(() => root.classList.remove('is-flowing'), up ? 1000 : 520);
      const from = getComputedStyle(surface).transform;
      slosh?.cancel();
      const s = up ? 1 : -1;
      slosh = surface.animate([
        { transform: from === 'none' ? 'scaleY(0.7)' : from },
        { transform: `rotate(${-5 * s}deg) scaleY(1.6)`, offset: 0.3 },
        { transform: `rotate(${2 * s}deg) scaleY(1.1)`, offset: 0.65 },
        { transform: 'rotate(0deg) scaleY(0.7)' },
      ], { duration: up ? 900 : 480, easing: 'ease-out' });
    };

    // The heart says no: a short shake when the request is refused
    const shake = () => {
      if (reduceMotion) return;
      svg.animate([
        { transform: 'none' },
        { transform: 'translateX(-2px)', offset: 0.2 },
        { transform: 'translateX(2px)', offset: 0.45 },
        { transform: 'translateX(-1px)', offset: 0.7 },
        { transform: 'none' },
      ], { duration: 360, easing: 'ease-out' });
    };

    // The level follows aria-pressed in CSS, so a click halfway turns it round where it is
    const apply = (next, n) => {
      const turned = next !== liked;
      liked = next;
      total = n;
      root.setAttribute('aria-pressed', String(next));
      root.dataset.count = String(n);
      label(n);
      if (turned) flow(next);
      later(next ? LAG_UP : LAG_DOWN);
    };

    let seq = 0;
    root.addEventListener('click', () => {
      const before = { liked, total };
      const next = !liked;
      const n = Math.max(0, total + (next ? 1 : -1));
      let request = null;
      const allowed = root.dispatchEvent(new CustomEvent('kodza:like', {
        bubbles: true,
        cancelable: true,
        detail: { liked: next, count: n, wait: (promise) => { request = Promise.resolve(promise); } },
      }));
      if (!allowed) return;
      const mine = ++seq;
      root.classList.add('is-spent');
      apply(next, n);
      say(next ? words.liked : words.unliked);
      request?.then((value) => {
        const real = typeof value === 'number' ? value : value?.count;
        if (signal.aborted || mine !== seq || !Number.isFinite(real)) return;
        total = Math.max(0, Math.round(real));
        root.dataset.count = String(total);
        label(total);
        if (!lag) roll(total);
      }, () => {
        if (signal.aborted || mine !== seq) return;
        apply(before.liked, before.total);
        shake();
        say(words.refused);
      });
    }, { signal });

    // After a click the drop under the pointer waits for the next visit
    root.addEventListener('pointerleave', () => root.classList.remove('is-spent'), { signal });

    // Set from your code: aria-pressed fills or drains the heart, data-count rolls the count
    const observer = new MutationObserver(() => {
      const pressed = root.getAttribute('aria-pressed') === 'true';
      const n = countOf();
      if (pressed !== liked) {
        liked = pressed;
        flow(liked);
      }
      if (n !== total) {
        total = n;
        label(n);
        later(LAG_DOWN);
      }
    });
    observer.observe(root, { attributes: true, attributeFilter: ['aria-pressed', 'data-count'] });

    paint(shown);
    label(shown);
    signal.addEventListener('abort', () => {
      clearTimeout(lag);
      clearTimeout(flowTimer);
      clearTimeout(sayTimer);
      observer.disconnect();
      slosh?.cancel();
      status.remove();
    });
  }

  // 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. Each running root
  // keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
  // component inside another one is saved as written, not half-started, and stopped with it.
  const KODZA = Symbol.for('kodza');
  const instances = new WeakMap();
  const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
  const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
  const put = (el, saved) => {
    [...el.attributes].forEach((a) => el.removeAttribute(a.name));
    saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
    el.innerHTML = saved.html;
  };
  // The markup inside a root as written: Kodza components already running in it give back their own
  const written = (root) => {
    const all = [...root.querySelectorAll('*')];
    if (!all.some((el) => el[KODZA])) return root.innerHTML;
    const copy = root.cloneNode(true);
    const twins = copy.querySelectorAll('*');
    let last = null;
    all.forEach((el, i) => {
      if (!el[KODZA] || last?.contains(el)) return;
      last = el;
      put(twins[i], el[KODZA]);
    });
    return copy.innerHTML;
  };
  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();
    const saved = { html: written(root), attrs: attrsOf(root), stop: () => destroy(root) };
    instances.set(root, { controller, saved });
    root[KODZA] = saved;
    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);
    // The Kodza components running inside it stop first: once its markup is put back, their own
    // script could not find them any more
    root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
    instance.controller.abort();
    delete root[KODZA];
    put(root, instance.saved);
  });
  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 });
})();
```

Free to use, from Kodza (https://kodza.dev).
