# Table

> A data table that sorts when you click a column: rows glide to their new place, the sorted column gets a soft band, the header stays on top and the edges fade while it scrolls.

Data display · table, data, sort, grid · HTML, CSS, vanilla JS · no dependencies · updated 2026-10-21
Demo: https://kodza.dev/components/table/

## Files

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

- [`kodza-table.css`](https://kodza.dev/registry/table/kodza-table.css) · 16.7 KB
- [`kodza-table.js`](https://kodza.dev/registry/table/kodza-table.js) · 4.9 KB
- [`kodza-table.html`](https://kodza.dev/registry/table/kodza-table.html) · 5.0 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-table.css https://kodza.dev/registry/table/kodza-table.css
curl -fsSL --create-dirs -o kodza/kodza-table.js https://kodza.dev/registry/table/kodza-table.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-table`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-table-bg: #ffffff`
  - `--kz-table-fg: #0a0a0a`
  - `--kz-table-muted: rgba(10, 10, 10, 0.6)`
  - `--kz-table-line: rgba(10, 10, 10, 0.09)`
  - `--kz-table-border: rgba(10, 10, 10, 0.1)`
  - `--kz-table-soft: rgba(10, 10, 10, 0.035)`
  - `--kz-table-ink: #0a0a0a`
  - `--kz-table-on-ink: #ffffff`
  - `--kz-table-max: none`
  - `--kz-table-ease: cubic-bezier(0.22, 1, 0.36, 1)`
- Attributes:
  - `data-sort` (e.g. `2.1`, `12480`, `2026-10-02`, `6.8`, `9312`, `2026-10-16`)
  - `data-status` (e.g. `beta`, `new`, `deprecated`, `stable`)
- Lifecycle: `kodza:init` / `kodza:destroy` on `document`, with `{ detail: { root } }` to target a container.

## 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-table {
    --kz-table-bg: #161616;
    --kz-table-fg: #f2f2f0;
    --kz-table-muted: rgba(242, 242, 240, 0.6);
    --kz-table-line: rgba(255, 255, 255, 0.08);
    --kz-table-border: rgba(255, 255, 255, 0.12);
    --kz-table-soft: rgba(255, 255, 255, 0.04);
    --kz-table-ink: #f2f2f0;
    --kz-table-on-ink: #0a0a0a;
  }
}
```

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

## Use it

### Plain HTML page

- CSS: `kodza/kodza-table.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-table.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-table.js`, loaded with `<script src="kodza/kodza-table.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-table.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-table.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.
- 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-table', $uri . 'kodza-table.css', [], filemtime($dir . 'kodza-table.css'));
    wp_enqueue_script('kodza-table', $uri . 'kodza-table.js', [], filemtime($dir . 'kodza-table.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: by default, match the theme's palette. After the component's CSS, point these variables at the theme's colours, on the component root, Kodza's value as the fallback:
  `.kodza-table { --kz-table-fg: var(TEXT, #0a0a0a); --kz-table-bg: var(BACKGROUND, #ffffff); --kz-table-ink: var(ACCENT, #0a0a0a); --kz-table-on-ink: var(BACKGROUND, #ffffff); }`
  TEXT, BACKGROUND and ACCENT (the colour the theme fills its own buttons with) are the theme's own colour variables — block themes (theme.json, like Twenty Twenty-Five): `--wp--preset--color--contrast`, `--wp--preset--color--base`, `--wp--preset--color--contrast` (they fill their buttons with it; their accent-1… colours are decorative); Astra: `--ast-global-color-2`, `--ast-global-color-4`, `--ast-global-color-0`; Kadence: `--global-palette3`, `--global-palette9`, `--global-palette1`; GeneratePress: `--contrast`, `--base-3`, `--accent`; Blocksy: `--theme-palette-color-4`, `--theme-palette-color-8`, `--theme-palette-color-1`. Use only these names, and only if the site really has them (the theme's CSS, or Styles → Colors): the `--wp--preset--color--black`, `--white`, `--vivid-…` that WordPress adds everywhere are not the theme's palette. Another theme, or one without these variables (Hello Elementor, OceanWP): leave the variables alone, it keeps Kodza's monochrome; same when the developer asks for monochrome or the Kodza look. Leave the translucent greys (`rgba(10, 10, 10, …)`) as they are: they suit any light background. On a dark palette, set the other variables from Dark mode too.
- 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-table.css` and `assets/kodza-table.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-table.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-table.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/`): `Table.tsx` (below), the CSS block under Code saved as `table.css` and the JS block as `table.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { Table } from '@/components/kodza/Table';` then `<Table />`. Props: `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-table-bg': … }}`), `className`, `style` and the other props of its `<div>` (`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 './table.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.

```tsx
'use client';
// Kodza — Table, for React. From https://kodza.dev/components/table/
// 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: table.css and table.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 './table.css';

export type TableProps = Omit<ComponentPropsWithoutRef<'div'>, "children" | "vars"> & {
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #ffffff */
    "--kz-table-bg"?: string | number;
    /** default: #0a0a0a */
    "--kz-table-fg"?: string | number;
    /** default: rgba(10, 10, 10, 0.6) */
    "--kz-table-muted"?: string | number;
    /** default: rgba(10, 10, 10, 0.09) */
    "--kz-table-line"?: string | number;
    /** default: rgba(10, 10, 10, 0.1) */
    "--kz-table-border"?: string | number;
    /** default: rgba(10, 10, 10, 0.035) */
    "--kz-table-soft"?: string | number;
    /** default: #0a0a0a */
    "--kz-table-ink"?: string | number;
    /** default: #ffffff */
    "--kz-table-on-ink"?: string | number;
    /** default: none */
    "--kz-table-max"?: string | number;
    /** default: cubic-bezier(0.22, 1, 0.36, 1) */
    "--kz-table-ease"?: string | number;
  };
  className?: string;
};

export function Table({ vars, className, style, ...rest }: TableProps) {
  const ref = useRef<ComponentRef<'div'>>(null);
  const classes = ["kodza-table", 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('./table.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 (
    <div role="region" aria-label="Most copied components" tabIndex={0} key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <table>
        <thead>
          <tr>
            <th scope="col">
              <button className="kodza-table__sort" type="button">Component<svg viewBox="0 0 12 12" aria-hidden="true"> <path d="M6 2.5v7M3 6.5l3 3 3-3" /> </svg></button>
            </th>
            <th scope="col">
              <button className="kodza-table__sort" type="button">Category<svg viewBox="0 0 12 12" aria-hidden="true"> <path d="M6 2.5v7M3 6.5l3 3 3-3" /> </svg></button>
            </th>
            <th scope="col" className="kodza-table__num">
              <button className="kodza-table__sort" type="button">Size<svg viewBox="0 0 12 12" aria-hidden="true"> <path d="M6 2.5v7M3 6.5l3 3 3-3" /> </svg></button>
            </th>
            <th scope="col" className="kodza-table__num" aria-sort="descending">
              <button className="kodza-table__sort" type="button">Copies<svg viewBox="0 0 12 12" aria-hidden="true"> <path d="M6 2.5v7M3 6.5l3 3 3-3" /> </svg></button>
            </th>
            <th scope="col" className="kodza-table__num">
              <button className="kodza-table__sort" type="button">Updated<svg viewBox="0 0 12 12" aria-hidden="true"> <path d="M6 2.5v7M3 6.5l3 3 3-3" /> </svg></button>
            </th>
            <th scope="col">Status</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>
              <span className="kodza-table__name">Fill Button</span>
              <span className="kodza-table__slug">button-fill</span>
            </td>
            <td>Buttons</td>
            <td className="kodza-table__num" data-sort="2.1">2.1 KB</td>
            <td className="kodza-table__num" data-sort="12480">12,480</td>
            <td className="kodza-table__num" data-sort="2026-10-02">
              <time dateTime="2026-10-02">Oct 2</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="stable">Stable</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Toast</span>
              <span className="kodza-table__slug">toast-notification</span>
            </td>
            <td>Overlays</td>
            <td className="kodza-table__num" data-sort="6.8">6.8 KB</td>
            <td className="kodza-table__num" data-sort="9312">9,312</td>
            <td className="kodza-table__num" data-sort="2026-10-16">
              <time dateTime="2026-10-16">Oct 16</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="stable">Stable</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Command Palette</span>
              <span className="kodza-table__slug">command-palette</span>
            </td>
            <td>Navigation</td>
            <td className="kodza-table__num" data-sort="9.4">9.4 KB</td>
            <td className="kodza-table__num" data-sort="7045">7,045</td>
            <td className="kodza-table__num" data-sort="2026-10-14">
              <time dateTime="2026-10-14">Oct 14</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="beta">Beta</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Skeleton</span>
              <span className="kodza-table__slug">skeleton-loader</span>
            </td>
            <td>Feedback</td>
            <td className="kodza-table__num" data-sort="4.2">4.2 KB</td>
            <td className="kodza-table__num" data-sort="5980">5,980</td>
            <td className="kodza-table__num" data-sort="2026-10-16">
              <time dateTime="2026-10-16">Oct 16</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="new">New</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Image Gallery</span>
              <span className="kodza-table__slug">image-gallery</span>
            </td>
            <td>Images</td>
            <td className="kodza-table__num" data-sort="7.7">7.7 KB</td>
            <td className="kodza-table__num" data-sort="5214">5,214</td>
            <td className="kodza-table__num" data-sort="2026-09-28">
              <time dateTime="2026-09-28">Sep 28</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="stable">Stable</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Date Picker</span>
              <span className="kodza-table__slug">date-picker</span>
            </td>
            <td>Forms</td>
            <td className="kodza-table__num" data-sort="11.2">11.2 KB</td>
            <td className="kodza-table__num" data-sort="4871">4,871</td>
            <td className="kodza-table__num" data-sort="2026-10-12">
              <time dateTime="2026-10-12">Oct 12</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="beta">Beta</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Marquee</span>
              <span className="kodza-table__slug">scrolling-text-loop</span>
            </td>
            <td>Text</td>
            <td className="kodza-table__num" data-sort="1.3">1.3 KB</td>
            <td className="kodza-table__num" data-sort="3902">3,902</td>
            <td className="kodza-table__num" data-sort="2026-08-30">
              <time dateTime="2026-08-30">Aug 30</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="stable">Stable</span>
            </td>
          </tr>
          <tr>
            <td>
              <span className="kodza-table__name">Alert Dialog</span>
              <span className="kodza-table__slug">alert-dialog</span>
            </td>
            <td>Overlays</td>
            <td className="kodza-table__num" data-sort="3.9">3.9 KB</td>
            <td className="kodza-table__num" data-sort="1204">1,204</td>
            <td className="kodza-table__num" data-sort="2026-03-03">
              <time dateTime="2026-03-03">Mar 3</time>
            </td>
            <td>
              <span className="kodza-table__status" data-status="deprecated">Deprecated</span>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  );
}
```

## Code

```html
<div class="kodza-table" role="region" aria-label="Most copied components" tabindex="0">
  <table>
    <thead>
      <tr>
        <th scope="col"><button class="kodza-table__sort" type="button">Component<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 2.5v7M3 6.5l3 3 3-3" /></svg></button></th>
        <th scope="col"><button class="kodza-table__sort" type="button">Category<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 2.5v7M3 6.5l3 3 3-3" /></svg></button></th>
        <th scope="col" class="kodza-table__num"><button class="kodza-table__sort" type="button">Size<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 2.5v7M3 6.5l3 3 3-3" /></svg></button></th>
        <th scope="col" class="kodza-table__num" aria-sort="descending"><button class="kodza-table__sort" type="button">Copies<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 2.5v7M3 6.5l3 3 3-3" /></svg></button></th>
        <th scope="col" class="kodza-table__num"><button class="kodza-table__sort" type="button">Updated<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 2.5v7M3 6.5l3 3 3-3" /></svg></button></th>
        <th scope="col">Status</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="kodza-table__name">Fill Button</span><span class="kodza-table__slug">button-fill</span></td>
        <td>Buttons</td>
        <td class="kodza-table__num" data-sort="2.1">2.1 KB</td>
        <td class="kodza-table__num" data-sort="12480">12,480</td>
        <td class="kodza-table__num" data-sort="2026-10-02"><time datetime="2026-10-02">Oct 2</time></td>
        <td><span class="kodza-table__status" data-status="stable">Stable</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Toast</span><span class="kodza-table__slug">toast-notification</span></td>
        <td>Overlays</td>
        <td class="kodza-table__num" data-sort="6.8">6.8 KB</td>
        <td class="kodza-table__num" data-sort="9312">9,312</td>
        <td class="kodza-table__num" data-sort="2026-10-16"><time datetime="2026-10-16">Oct 16</time></td>
        <td><span class="kodza-table__status" data-status="stable">Stable</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Command Palette</span><span class="kodza-table__slug">command-palette</span></td>
        <td>Navigation</td>
        <td class="kodza-table__num" data-sort="9.4">9.4 KB</td>
        <td class="kodza-table__num" data-sort="7045">7,045</td>
        <td class="kodza-table__num" data-sort="2026-10-14"><time datetime="2026-10-14">Oct 14</time></td>
        <td><span class="kodza-table__status" data-status="beta">Beta</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Skeleton</span><span class="kodza-table__slug">skeleton-loader</span></td>
        <td>Feedback</td>
        <td class="kodza-table__num" data-sort="4.2">4.2 KB</td>
        <td class="kodza-table__num" data-sort="5980">5,980</td>
        <td class="kodza-table__num" data-sort="2026-10-16"><time datetime="2026-10-16">Oct 16</time></td>
        <td><span class="kodza-table__status" data-status="new">New</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Image Gallery</span><span class="kodza-table__slug">image-gallery</span></td>
        <td>Images</td>
        <td class="kodza-table__num" data-sort="7.7">7.7 KB</td>
        <td class="kodza-table__num" data-sort="5214">5,214</td>
        <td class="kodza-table__num" data-sort="2026-09-28"><time datetime="2026-09-28">Sep 28</time></td>
        <td><span class="kodza-table__status" data-status="stable">Stable</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Date Picker</span><span class="kodza-table__slug">date-picker</span></td>
        <td>Forms</td>
        <td class="kodza-table__num" data-sort="11.2">11.2 KB</td>
        <td class="kodza-table__num" data-sort="4871">4,871</td>
        <td class="kodza-table__num" data-sort="2026-10-12"><time datetime="2026-10-12">Oct 12</time></td>
        <td><span class="kodza-table__status" data-status="beta">Beta</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Marquee</span><span class="kodza-table__slug">scrolling-text-loop</span></td>
        <td>Text</td>
        <td class="kodza-table__num" data-sort="1.3">1.3 KB</td>
        <td class="kodza-table__num" data-sort="3902">3,902</td>
        <td class="kodza-table__num" data-sort="2026-08-30"><time datetime="2026-08-30">Aug 30</time></td>
        <td><span class="kodza-table__status" data-status="stable">Stable</span></td>
      </tr>
      <tr>
        <td><span class="kodza-table__name">Alert Dialog</span><span class="kodza-table__slug">alert-dialog</span></td>
        <td>Overlays</td>
        <td class="kodza-table__num" data-sort="3.9">3.9 KB</td>
        <td class="kodza-table__num" data-sort="1204">1,204</td>
        <td class="kodza-table__num" data-sort="2026-03-03"><time datetime="2026-03-03">Mar 3</time></td>
        <td><span class="kodza-table__status" data-status="deprecated">Deprecated</span></td>
      </tr>
    </tbody>
  </table>
</div>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Table
   A data table that sorts when you click a column title: the rows glide to their new place,
   the sorted column gets a soft band and an arrow that turns with the order. Numbers are
   right-aligned in tabular figures. The header stays put when the table scrolls
   (--kz-table-max sets a height), and the edges fade while there is more to scroll sideways.
   A status is told by a shape: a full dot, a ring, an ink pill, or struck through.
   Everything is tuned with the --kz-table-* variables. */
.kodza-table {
  --kz-table-bg: #ffffff;
  --kz-table-fg: #0a0a0a;
  --kz-table-muted: rgba(10, 10, 10, 0.6);
  --kz-table-line: rgba(10, 10, 10, 0.09);
  --kz-table-border: rgba(10, 10, 10, 0.1);
  --kz-table-soft: rgba(10, 10, 10, 0.035);
  --kz-table-ink: #0a0a0a;
  --kz-table-on-ink: #ffffff;
  --kz-table-max: none;
  --kz-table-fade-l: 0px;
  --kz-table-fade-r: 0px;
  --kz-table-ease: cubic-bezier(0.22, 1, 0.36, 1);

  max-height: var(--kz-table-max);
  overflow: auto;
  border-radius: 16px;
  background: var(--kz-table-bg);
  box-shadow: inset 0 0 0 1px var(--kz-table-border);
  color: var(--kz-table-fg);
  font-size: 14px;
  -webkit-mask: linear-gradient(to right, transparent, #000 var(--kz-table-fade-l), #000 calc(100% - var(--kz-table-fade-r)), transparent);
  mask: linear-gradient(to right, transparent, #000 var(--kz-table-fade-l), #000 calc(100% - var(--kz-table-fade-r)), transparent);
}

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

.kodza-table table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.kodza-table th,
.kodza-table td {
  height: 52px;
  padding: 0 18px;
  text-align: left;
}

.kodza-table th:first-child,
.kodza-table td:first-child {
  padding-left: 24px;
}

.kodza-table th:last-child,
.kodza-table td:last-child {
  padding-right: 24px;
}

/* The header: stays on top when the table scrolls */
.kodza-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 46px;
  background: var(--kz-table-bg);
  box-shadow: inset 0 -1px 0 var(--kz-table-border);
  color: var(--kz-table-muted);
  font-size: 13px;
  font-weight: 500;
}

.kodza-table__sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 -8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.kodza-table__sort:hover {
  background: var(--kz-table-soft);
  color: var(--kz-table-fg);
}

.kodza-table__sort:focus-visible {
  outline: 2px solid var(--kz-table-fg);
  outline-offset: 1px;
}

.kodza-table__sort svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.45s var(--kz-table-ease);
}

.kodza-table__sort:hover svg {
  opacity: 0.4;
  transform: none;
}

.kodza-table th[aria-sort] {
  color: var(--kz-table-fg);
}

.kodza-table th[aria-sort] svg {
  opacity: 1;
  transform: none;
}

.kodza-table th[aria-sort="ascending"] svg {
  transform: rotate(180deg);
}

/* The sorted column: a soft band */
.kodza-table td.is-sorted {
  background: var(--kz-table-soft);
}

.kodza-table th.kodza-table__num,
.kodza-table td.kodza-table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kodza-table th.kodza-table__num .kodza-table__sort {
  flex-direction: row-reverse;
}

/* Rows have a body: two rows crossing while they glide never mix their words */
.kodza-table tbody tr {
  position: relative;
  background: var(--kz-table-bg);
}

.kodza-table tbody td {
  transition: background-color 0.2s ease;
}

.kodza-table tbody tr + tr td {
  border-top: 1px solid var(--kz-table-line);
}

.kodza-table tbody tr:hover td {
  background-image: linear-gradient(var(--kz-table-soft), var(--kz-table-soft));
}

.kodza-table__name {
  display: block;
  font-weight: 500;
}

.kodza-table__slug {
  display: block;
  margin-top: 1px;
  color: var(--kz-table-muted);
  font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
}

.kodza-table tbody td:has(.kodza-table__name) {
  height: 60px;
}

/* Status: a shape says it, not a color */
.kodza-table__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.kodza-table__status::before {
  content: "";
  width: 7px;
  height: 7px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--kz-table-ink);
}

.kodza-table__status[data-status="beta"]::before {
  background: none;
  border: 1.5px solid var(--kz-table-ink);
}

.kodza-table__status[data-status="new"] {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--kz-table-ink);
  color: var(--kz-table-on-ink);
  font-size: 12px;
  font-weight: 500;
}

.kodza-table__status[data-status="new"]::before {
  display: none;
}

.kodza-table__status[data-status="deprecated"] {
  color: var(--kz-table-muted);
  text-decoration: line-through;
}

.kodza-table__status[data-status="deprecated"]::before {
  width: 8px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--kz-table-muted);
}

@media (prefers-reduced-motion: reduce) {
  .kodza-table__sort,
  .kodza-table__sort svg,
  .kodza-table tbody td {
    transition-duration: 0.01ms !important;
  }
}

/* Theming example — on a dark background:
.dark-section .kodza-table {
  --kz-table-bg: #161616;
  --kz-table-fg: #f2f2f0;
  --kz-table-muted: rgba(242, 242, 240, 0.6);
  --kz-table-line: rgba(255, 255, 255, 0.08);
  --kz-table-border: rgba(255, 255, 255, 0.12);
  --kz-table-soft: rgba(255, 255, 255, 0.04);
  --kz-table-ink: #f2f2f0;
  --kz-table-on-ink: #0a0a0a;
}
*/

/* kodza-guard 866cc02513fd — 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-table):not(#_),
:where(.kodza-table__sort):not(#_) {
  outline: revert;
  outline-offset: revert;
}

:where(.kodza-table__num):not(#_) {
  transition: revert;
  position: revert;
  border-top-width: revert;
  border-top-style: revert;
  border-top-color: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  color: revert;
  font-size: revert;
  font-weight: revert;
}

:where(.kodza-table tr:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *))):not(#_) {
  position: revert;
  background-color: revert;
  background-image: revert;
}

:where(.kodza-table td:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *))):not(#_) {
  border-top-width: revert;
  border-top-style: revert;
  border-top-color: revert;
  background-color: revert;
  background-image: revert;
}

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

.kodza-table:not(#_),
.kodza-table__name:not(#_),
.kodza-table__slug:not(#_),
.kodza-table__status:not(#_) {
  box-sizing: revert;
}

.kodza-table__sort:not(#_) {
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  white-space: revert;
  min-height: revert;
}

.kodza-table__num:not(#_) {
  margin: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  border-right-width: revert;
  border-bottom-width: revert;
  border-left-width: revert;
  border-right-style: revert;
  border-bottom-style: revert;
  border-left-style: revert;
  border-right-color: revert;
  border-bottom-color: revert;
  border-left-color: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-family: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-table table:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_),
.kodza-table thead:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_),
.kodza-table tbody:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_),
.kodza-table__num time:where(:not([class*="kodza-"])):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;
  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-table tr:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):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;
  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-table th:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_) {
  border: revert;
  margin: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-family: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-table__sort svg:where(:not([class*="kodza-"])):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-table td:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_) {
  margin: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  border-right-width: revert;
  border-bottom-width: revert;
  border-left-width: revert;
  border-right-style: revert;
  border-bottom-style: revert;
  border-left-style: revert;
  border-right-color: revert;
  border-bottom-color: revert;
  border-left-color: 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-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-table__num:not(#_):where(:not([hidden])),
.kodza-table table:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-table thead:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-table tr:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-table th:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-table__sort svg:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])),
.kodza-table tbody:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-table td:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-table__num time:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-table__num:not(#_):where([hidden]),
.kodza-table table:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-table thead:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-table tr:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-table th:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-table__sort svg:where(:not([class*="kodza-"])):not(#_):where([hidden]),
.kodza-table tbody:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-table td:where(:not([class*="kodza-"]):not(.kodza-table [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-table__num time:where(:not([class*="kodza-"])):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-table:not(#_) {
  box-shadow: inset 0 0 0 1px var(--kz-table-border);
}

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

.kodza-table th:not(#_),
.kodza-table td:not(#_) {
  padding: 0 18px;
  text-align: left;
}

.kodza-table th:first-child:not(#_),
.kodza-table td:first-child:not(#_) {
  padding-left: 24px;
}

.kodza-table th:last-child:not(#_),
.kodza-table td:last-child:not(#_) {
  padding-right: 24px;
}

.kodza-table thead th:not(#_) {
  position: sticky;
  background: var(--kz-table-bg);
  box-shadow: inset 0 -1px 0 var(--kz-table-border);
  color: var(--kz-table-muted);
  font-size: 13px;
  font-weight: 500;
}

.kodza-table__sort:not(#_) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 -8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.kodza-table__sort:hover:not(#_) {
  background: var(--kz-table-soft);
  color: var(--kz-table-fg);
}

.kodza-table__sort:focus-visible:not(#_) {
  outline: 2px solid var(--kz-table-fg);
  outline-offset: 1px;
}

.kodza-table__sort svg:not(#_) {
  transition: opacity 0.2s ease, transform 0.45s var(--kz-table-ease);
}

.kodza-table th[aria-sort]:not(#_) {
  color: var(--kz-table-fg);
}

.kodza-table td.is-sorted:not(#_) {
  background: var(--kz-table-soft);
}

.kodza-table th.kodza-table__num:not(#_),
.kodza-table td.kodza-table__num:not(#_) {
  text-align: right;
}

.kodza-table th.kodza-table__num .kodza-table__sort:not(#_) {
  flex-direction: row-reverse;
}

.kodza-table tbody tr:not(#_) {
  position: relative;
  background: var(--kz-table-bg);
}

.kodza-table tbody td:not(#_) {
  transition: background-color 0.2s ease;
}

.kodza-table tbody tr + tr td:not(#_) {
  border-top: 1px solid var(--kz-table-line);
}

.kodza-table tbody tr:hover td:not(#_) {
  background-image: linear-gradient(var(--kz-table-soft), var(--kz-table-soft));
}

@media (prefers-reduced-motion: reduce) {
  .kodza-table__sort:not(#_) {
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-table__sort svg:not(#_),
  .kodza-table tbody td:not(#_) {
    transition-duration: 0.01ms !important;
  }
}
```

```js
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Table
// Sorts by the clicked column (numbers and dates by their data-sort value, words by their
// text), keeps aria-sort in step and glides each row from its old place to its new one. Also
// fades the edges while there is more to scroll sideways.
(() => {
  const SELECTOR = '.kodza-table';
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  const ease = 'cubic-bezier(0.22, 1, 0.36, 1)';

  // One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
  function mount(root, signal) {
    const tbody = root.querySelector('tbody');
    const headers = [...root.querySelectorAll('thead th')];
    if (!tbody) return;

    const value = (row, index) => {
      const cell = row.children[index];
      const raw = cell?.dataset.sort ?? cell?.textContent.trim() ?? '';
      const number = Number(raw);
      return raw !== '' && !Number.isNaN(number) ? number : raw.toLowerCase();
    };

    const mark = (index) => [...tbody.rows].forEach((row) => [...row.children].forEach((cell, i) => cell.classList.toggle('is-sorted', i === index)));

    const sort = (th) => {
      const index = headers.indexOf(th);
      const numeric = th.classList.contains('kodza-table__num');
      const current = th.getAttribute('aria-sort');
      // A new column starts from the most telling end: biggest numbers, first letters
      const order = current ? (current === 'ascending' ? 'descending' : 'ascending') : numeric ? 'descending' : 'ascending';
      headers.forEach((other) => other !== th && other.removeAttribute('aria-sort'));
      th.setAttribute('aria-sort', order);

      const rows = [...tbody.rows];
      const k = root.getBoundingClientRect().width / root.offsetWidth || 1;
      const before = new Map(rows.map((row) => [row, row.getBoundingClientRect().top]));
      rows.sort((a, b) => {
        const x = value(a, index);
        const y = value(b, index);
        const result = typeof x === 'number' && typeof y === 'number' ? x - y : String(x).localeCompare(String(y));
        return order === 'ascending' ? result : -result;
      });
      tbody.append(...rows);
      mark(index);
      if (reduceMotion) return;
      rows.forEach((row, i) => {
        const dy = (before.get(row) - row.getBoundingClientRect().top) / k;
        if (dy) row.animate([{ transform: `translateY(${dy}px)` }, { transform: 'none' }], { duration: 620, delay: Math.min(i, 8) * 18, easing: ease, fill: 'backwards' });
      });
    };

    headers.forEach((th) => th.querySelector('.kodza-table__sort')?.addEventListener('click', () => sort(th), { signal }));
    const sorted = headers.find((th) => th.hasAttribute('aria-sort'));
    if (sorted) mark(headers.indexOf(sorted));

    // The edges fade while there is more to see sideways
    const edges = () => {
      const more = root.scrollWidth - root.clientWidth;
      root.style.setProperty('--kz-table-fade-l', root.scrollLeft > 2 ? '32px' : '0px');
      root.style.setProperty('--kz-table-fade-r', more - root.scrollLeft > 2 ? '32px' : '0px');
    };
    edges();
    root.addEventListener('scroll', edges, { passive: true, signal });
    const observer = new ResizeObserver(edges);
    observer.observe(root);
    signal.addEventListener('abort', () => observer.disconnect());
  }

  // 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 });
})();
```

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