# Sheet

> A panel that slides in from the right, and on phones rises from the bottom as a sheet you drag, with half and full stops and a flick to dismiss.

Overlays · sheet, drawer, dialog, mobile · HTML, CSS, vanilla JS · no dependencies · updated 2026-10-16
Demo: https://kodza.dev/components/drawer/

Takes the whole screen (or reacts to the page scroll): give it a page, not a small box.

## Files

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

- [`kodza-drawer.css`](https://kodza.dev/registry/drawer/kodza-drawer.css) · 22.8 KB
- [`kodza-drawer.js`](https://kodza.dev/registry/drawer/kodza-drawer.js) · 8.4 KB
- [`kodza-drawer.html`](https://kodza.dev/registry/drawer/kodza-drawer.html) · 1.6 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-drawer.css https://kodza.dev/registry/drawer/kodza-drawer.css
curl -fsSL --create-dirs -o kodza/kodza-drawer.js https://kodza.dev/registry/drawer/kodza-drawer.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-sheet`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-sheet-bg: #ffffff`
  - `--kz-sheet-fg: #0a0a0a`
  - `--kz-sheet-muted: rgba(10, 10, 10, 0.6)`
  - `--kz-sheet-line: rgba(10, 10, 10, 0.1)`
  - `--kz-sheet-soft: rgba(10, 10, 10, 0.05)`
  - `--kz-sheet-ink: #0a0a0a`
  - `--kz-sheet-on-ink: #ffffff`
  - `--kz-sheet-backdrop: rgba(10, 10, 10, 0.3)`
  - `--kz-sheet-width: 420px`
  - `--kz-sheet-radius: 20px`
  - `--kz-sheet-duration: 0.55s`
  - `--kz-sheet-ease: cubic-bezier(0.32, 0.72, 0, 1)`
- 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-sheet__trigger`):
  - `Enter` / `Space`: Opens it, focus goes into the panel
- In the panel (focus in `.kodza-sheet__panel`):
  - `Tab` / `Shift+Tab`: Next or previous control, the page behind is out of reach
- Anywhere, while it's open (while `.kodza-sheet__panel[open]` is on the page):
  - `Escape`: Closes it, focus back on the button

## 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-sheet {
    --kz-sheet-bg: #161616;
    --kz-sheet-fg: #f2f2f0;
    --kz-sheet-muted: rgba(242, 242, 240, 0.62);
    --kz-sheet-line: rgba(255, 255, 255, 0.12);
    --kz-sheet-soft: rgba(255, 255, 255, 0.07);
    --kz-sheet-ink: #f2f2f0;
    --kz-sheet-on-ink: #0a0a0a;
    --kz-sheet-backdrop: rgba(0, 0, 0, 0.55);
  }
}
```

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

Its images have dark versions next to them (`kz-block-1400.webp` → `kz-block-dark-1400.webp`). To swap them on a dark page: `<picture><source media="(prefers-color-scheme: dark)" srcset="…-dark-….webp"><img …></picture>`.

## Use it

### Plain HTML page

- CSS: `kodza/kodza-drawer.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-drawer.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-drawer.js`, loaded with `<script src="kodza/kodza-drawer.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-drawer.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-drawer.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">`.
- Images: the artifact blocks every other host, `kodza.dev` included, without an error. Embed each one as a `data:` URI, with a command if you can run one (`curl -s <url> | base64`; the 1400 px files weigh 10 to 30 KB), never by typing base64 out. If you can't run commands, keep the `<img>` with its `width` and `height`, and tell the user the picture stays blank inside the artifact.
- 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-drawer', $uri . 'kodza-drawer.css', [], filemtime($dir . 'kodza-drawer.css'));
    wp_enqueue_script('kodza-drawer', $uri . 'kodza-drawer.js', [], filemtime($dir . 'kodza-drawer.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-sheet { --kz-sheet-fg: var(TEXT, #0a0a0a); --kz-sheet-bg: var(BACKGROUND, #ffffff); --kz-sheet-ink: var(ACCENT, #0a0a0a); --kz-sheet-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-drawer.css` and `assets/kodza-drawer.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-drawer.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-drawer.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/`): `Sheet.tsx` (below), the CSS block under Code saved as `drawer.css` and the JS block as `drawer.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { Sheet } from '@/components/kodza/Sheet';` then `<Sheet />`. Props: `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-sheet-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 './drawer.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 — Sheet, for React. From https://kodza.dev/components/drawer/
// 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: drawer.css and drawer.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 './drawer.css';

export type SheetProps = Omit<ComponentPropsWithoutRef<'div'>, "children" | "vars"> & {
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #ffffff */
    "--kz-sheet-bg"?: string | number;
    /** default: #0a0a0a */
    "--kz-sheet-fg"?: string | number;
    /** default: rgba(10, 10, 10, 0.6) */
    "--kz-sheet-muted"?: string | number;
    /** default: rgba(10, 10, 10, 0.1) */
    "--kz-sheet-line"?: string | number;
    /** default: rgba(10, 10, 10, 0.05) */
    "--kz-sheet-soft"?: string | number;
    /** default: #0a0a0a */
    "--kz-sheet-ink"?: string | number;
    /** default: #ffffff */
    "--kz-sheet-on-ink"?: string | number;
    /** default: rgba(10, 10, 10, 0.3) */
    "--kz-sheet-backdrop"?: string | number;
    /** default: 420px */
    "--kz-sheet-width"?: string | number;
    /** default: 20px */
    "--kz-sheet-radius"?: string | number;
    /** default: 0.55s */
    "--kz-sheet-duration"?: string | number;
    /** default: cubic-bezier(0.32, 0.72, 0, 1) */
    "--kz-sheet-ease"?: string | number;
  };
  className?: string;
};

export function Sheet({ vars, className, style, ...rest }: SheetProps) {
  const ref = useRef<ComponentRef<'div'>>(null);
  const classes = ["kodza-sheet", 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('./drawer.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 key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <button className="kodza-sheet__trigger" type="button">Cart <span className="kodza-sheet__badge">3</span></button>
      <dialog className="kodza-sheet__panel">
        <div className="kodza-sheet__grip" aria-hidden="true">
          <span />
        </div>
        <header className="kodza-sheet__head">
          <h2 className="kodza-sheet__title">Your cart</h2>
          <button className="kodza-sheet__close" type="button" aria-label="Close">
            <svg viewBox="0 0 16 16" aria-hidden="true">
              <path d="M4 4l8 8M12 4l-8 8" />
            </svg>
          </button>
        </header>
        <ul className="kodza-sheet__items">
          <li className="kodza-sheet__item">
            <img src="https://kodza.dev/media/kz-block-1400.webp" alt="" />
            <span className="kodza-sheet__name">Fill Button<small>HTML, CSS, a pinch of JS</small></span>
            <span className="kodza-sheet__price">€0.00</span>
          </li>
          <li className="kodza-sheet__item">
            <img src="https://kodza.dev/media/kz-stack-1400.webp" alt="" />
            <span className="kodza-sheet__name">Sticky Cards<small>Scroll, then scroll some more</small></span>
            <span className="kodza-sheet__price">€0.00</span>
          </li>
          <li className="kodza-sheet__item">
            <img src="https://kodza.dev/media/kz-arch-1400.webp" alt="" />
            <span className="kodza-sheet__name">Date Picker<small>Fridays included, at your own risk</small></span>
            <span className="kodza-sheet__price">€0.00</span>
          </li>
        </ul>
        <footer className="kodza-sheet__foot">
          <p className="kodza-sheet__total">
            <span>Total</span>
            <b>€0.00</b>
          </p>
          <p className="kodza-sheet__note">Everything is free. The cart is just for the feeling.</p>
          <button className="kodza-sheet__cta" type="button">Copy everything</button>
        </footer>
      </dialog>
    </div>
  );
}
```

## Code

```html
<div class="kodza-sheet">
  <button class="kodza-sheet__trigger" type="button">Cart <span class="kodza-sheet__badge">3</span></button>
  <dialog class="kodza-sheet__panel">
    <div class="kodza-sheet__grip" aria-hidden="true"><span></span></div>
    <header class="kodza-sheet__head">
      <h2 class="kodza-sheet__title">Your cart</h2>
      <button class="kodza-sheet__close" type="button" aria-label="Close"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8"/></svg></button>
    </header>
    <ul class="kodza-sheet__items">
      <li class="kodza-sheet__item"><img src="https://kodza.dev/media/kz-block-1400.webp" alt=""><span class="kodza-sheet__name">Fill Button<small>HTML, CSS, a pinch of JS</small></span><span class="kodza-sheet__price">€0.00</span></li>
      <li class="kodza-sheet__item"><img src="https://kodza.dev/media/kz-stack-1400.webp" alt=""><span class="kodza-sheet__name">Sticky Cards<small>Scroll, then scroll some more</small></span><span class="kodza-sheet__price">€0.00</span></li>
      <li class="kodza-sheet__item"><img src="https://kodza.dev/media/kz-arch-1400.webp" alt=""><span class="kodza-sheet__name">Date Picker<small>Fridays included, at your own risk</small></span><span class="kodza-sheet__price">€0.00</span></li>
    </ul>
    <footer class="kodza-sheet__foot">
      <p class="kodza-sheet__total"><span>Total</span><b>€0.00</b></p>
      <p class="kodza-sheet__note">Everything is free. The cart is just for the feeling.</p>
      <button class="kodza-sheet__cta" type="button">Copy everything</button>
    </footer>
  </dialog>
</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 — Sheet
   A panel over the page, in a real dialog element: on a computer it slides in from the right; on a
   phone it rises from the bottom as a sheet you can drag, with stops at half height and full
   height, and a flick down sends it away. Its content arrives in a short cascade. The focus
   stays inside, Escape and a click on the page close it, the page behind does not scroll.
   Everything is tuned with the --kz-sheet-* variables. */
.kodza-sheet {
  --kz-sheet-bg: #ffffff;
  --kz-sheet-fg: #0a0a0a;
  --kz-sheet-muted: rgba(10, 10, 10, 0.6);
  --kz-sheet-line: rgba(10, 10, 10, 0.1);
  --kz-sheet-soft: rgba(10, 10, 10, 0.05);
  --kz-sheet-ink: #0a0a0a;
  --kz-sheet-on-ink: #ffffff;
  --kz-sheet-backdrop: rgba(10, 10, 10, 0.3);
  --kz-sheet-width: 420px;
  --kz-sheet-radius: 20px;
  --kz-sheet-duration: 0.55s;
  --kz-sheet-ease: cubic-bezier(0.32, 0.72, 0, 1);

  display: inline-block;
  color: var(--kz-sheet-fg);
}

.kodza-sheet__trigger,
.kodza-sheet__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--kz-sheet-ink);
  color: var(--kz-sheet-on-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.kodza-sheet__trigger:hover,
.kodza-sheet__cta:hover {
  opacity: 0.86;
}

.kodza-sheet__trigger:active,
.kodza-sheet__cta:active {
  transform: scale(0.97);
}

.kodza-sheet__badge {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--kz-sheet-on-ink);
  color: var(--kz-sheet-ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  box-sizing: border-box;
}

.kodza-sheet__trigger:focus-visible,
.kodza-sheet__cta:focus-visible,
.kodza-sheet__close:focus-visible {
  outline: 2px solid var(--kz-sheet-fg);
  outline-offset: 3px;
}

/* The panel: pinned to the right edge, full height */
.kodza-sheet__panel {
  position: fixed;
  inset: 8px 8px 8px auto;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: min(var(--kz-sheet-width), calc(100% - 16px));
  max-width: none;
  height: calc(100% - 16px);
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--kz-sheet-radius);
  background: var(--kz-sheet-bg);
  box-shadow: 0 0 0 1px var(--kz-sheet-line), -20px 0 60px -20px rgba(10, 10, 10, 0.3);
  color: var(--kz-sheet-fg);
  font: inherit;
  transform: translateX(calc(100% + 16px));
}

.kodza-sheet__panel:not([open]) {
  display: none;
}

.kodza-sheet__panel.is-open {
  transform: none;
}

.kodza-sheet__panel.is-moving {
  transition: transform var(--kz-sheet-duration) var(--kz-sheet-ease);
}

.kodza-sheet__panel::backdrop {
  background: transparent;
  transition: background-color var(--kz-sheet-duration) ease;
}

.kodza-sheet__panel.is-open::backdrop {
  background: var(--kz-sheet-backdrop);
}

.kodza-sheet__grip {
  display: none;
  grid-row: 1;
}

.kodza-sheet__head {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px 24px;
}

.kodza-sheet__title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.kodza-sheet__close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kz-sheet-soft);
  color: var(--kz-sheet-fg);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.kodza-sheet__close:hover {
  background: var(--kz-sheet-line);
}

.kodza-sheet__close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.kodza-sheet__items {
  grid-row: 3;
  margin: 0;
  padding: 0 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.kodza-sheet__item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--kz-sheet-line);
}

.kodza-sheet__item img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
}

.kodza-sheet__name {
  display: grid;
  gap: 2px;
  font-size: 15px;
  font-weight: 500;
}

.kodza-sheet__name small {
  font-size: 13px;
  font-weight: 400;
  color: var(--kz-sheet-muted);
}

.kodza-sheet__price {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
}

.kodza-sheet__foot {
  grid-row: 4;
  display: grid;
  gap: 10px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--kz-sheet-line);
}

.kodza-sheet__total {
  display: flex;
  justify-content: space-between;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.kodza-sheet__total b {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 500;
}

.kodza-sheet__note {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--kz-sheet-muted);
}

.kodza-sheet__cta {
  width: 100%;
  height: 48px;
}

/* The content arrives in a short cascade once the panel is moving in */
.kodza-sheet__panel.is-open .kodza-sheet__head,
.kodza-sheet__panel.is-open .kodza-sheet__item,
.kodza-sheet__panel.is-open .kodza-sheet__foot {
  animation: kodza-sheet-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(0.12s + var(--i, 0) * 50ms);
}

@keyframes kodza-sheet-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* Phones: a sheet from the bottom, with a grip, stops at half and full height */
@media (max-width: 640px) {
  .kodza-sheet__panel {
    inset: auto 0 0;
    width: 100%;
    height: calc(100% - 40px);
    border-radius: var(--kz-sheet-radius) var(--kz-sheet-radius) 0 0;
    box-shadow: 0 -20px 60px -20px rgba(10, 10, 10, 0.3);
    transform: translateY(100%);
    touch-action: none;
  }

  .kodza-sheet__panel.is-open {
    transform: translateY(var(--kz-sheet-y, 0px));
  }

  .kodza-sheet__grip {
    display: grid;
    place-items: center;
    height: 22px;
    cursor: grab;
  }

  .kodza-sheet__grip span {
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: var(--kz-sheet-line);
  }

  .kodza-sheet__head {
    padding-top: 4px;
  }

  .kodza-sheet__items {
    touch-action: pan-y;
  }

  /* The total and the button stay at the bottom of the screen, whatever the stop */
  .kodza-sheet__foot {
    position: relative;
    z-index: 1;
    background: var(--kz-sheet-bg);
    transform: translateY(calc(var(--kz-sheet-y, 0px) * -1));
  }

  .kodza-sheet__panel.is-moving .kodza-sheet__foot {
    transition: transform var(--kz-sheet-duration) var(--kz-sheet-ease);
  }

  @keyframes kodza-sheet-in {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-sheet__panel.is-moving,
  .kodza-sheet__panel::backdrop,
  .kodza-sheet__trigger,
  .kodza-sheet__cta {
    transition-duration: 0.01ms !important;
  }

  .kodza-sheet__panel.is-open .kodza-sheet__head,
  .kodza-sheet__panel.is-open .kodza-sheet__item,
  .kodza-sheet__panel.is-open .kodza-sheet__foot {
    animation: none;
  }
}

/* Theming example — on a dark background:
.dark-section .kodza-sheet {
  --kz-sheet-bg: #161616;
  --kz-sheet-fg: #f2f2f0;
  --kz-sheet-muted: rgba(242, 242, 240, 0.62);
  --kz-sheet-line: rgba(255, 255, 255, 0.12);
  --kz-sheet-soft: rgba(255, 255, 255, 0.07);
  --kz-sheet-ink: #f2f2f0;
  --kz-sheet-on-ink: #0a0a0a;
  --kz-sheet-backdrop: rgba(0, 0, 0, 0.55);
}
*/

/* kodza-guard 89fced0e7f53 — 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-sheet__trigger):not(#_),
:where(.kodza-sheet__close):not(#_),
:where(.kodza-sheet__cta):not(#_) {
  outline: revert;
  outline-offset: revert;
}

:where(.kodza-sheet__panel):not(#_) {
  transition: revert;
}

:where(.kodza-sheet__foot):not(#_) {
  transition: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
}

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

.kodza-sheet:not(#_),
.kodza-sheet__grip:not(#_),
.kodza-sheet__name:not(#_),
.kodza-sheet__price:not(#_),
.kodza-sheet__grip span:where(:not([class*="kodza-"])):not(#_),
.kodza-sheet__total span:where(:not([class*="kodza-"])):not(#_) {
  box-sizing: revert;
}

.kodza-sheet__trigger:not(#_),
.kodza-sheet__cta:not(#_) {
  margin: revert;
  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-sheet__panel:not(#_) {
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  outline-offset: revert;
  appearance: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-sheet__head:not(#_) {
  border: revert;
  margin: 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-sheet__title:not(#_) {
  border: 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-style: revert;
  line-height: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-sheet__close:not(#_) {
  margin: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: 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;
  white-space: revert;
  min-height: revert;
}

.kodza-sheet__items:not(#_) {
  border: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: 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-sheet__item:not(#_) {
  margin: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  border-top-width: revert;
  border-right-width: revert;
  border-left-width: revert;
  border-top-style: revert;
  border-right-style: revert;
  border-left-style: revert;
  border-top-color: revert;
  border-right-color: revert;
  border-left-color: 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-sheet__foot: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;
  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-sheet__total:not(#_) {
  border: 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-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-sheet__note:not(#_) {
  border: 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;
  font-family: 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-sheet__close svg: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-sheet__item img:where(:not([class*="kodza-"])):not(#_) {
  border: revert;
  margin: revert;
  padding: 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-sheet__name small: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;
  font-family: 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-sheet__total b: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-size: 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-sheet__title:not(#_):where(:not([hidden])),
.kodza-sheet__items:not(#_):where(:not([hidden])),
.kodza-sheet__note:not(#_):where(:not([hidden])),
.kodza-sheet__close svg:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])),
.kodza-sheet__item img:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])),
.kodza-sheet__name small:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])),
.kodza-sheet__total b:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-sheet__title:not(#_):where([hidden]),
.kodza-sheet__items:not(#_):where([hidden]),
.kodza-sheet__note:not(#_):where([hidden]),
.kodza-sheet__close svg:where(:not([class*="kodza-"])):not(#_):where([hidden]),
.kodza-sheet__item img:where(:not([class*="kodza-"])):not(#_):where([hidden]),
.kodza-sheet__name small:where(:not([class*="kodza-"])):not(#_):where([hidden]),
.kodza-sheet__total b: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-sheet__trigger:not(#_),
.kodza-sheet__cta:not(#_) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--kz-sheet-ink);
  color: var(--kz-sheet-on-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.kodza-sheet__trigger:hover:not(#_),
.kodza-sheet__cta:hover:not(#_) {
  opacity: 0.86;
}

.kodza-sheet__trigger:active:not(#_),
.kodza-sheet__cta:active:not(#_) {
  transform: scale(0.97);
}

.kodza-sheet__trigger:focus-visible:not(#_),
.kodza-sheet__cta:focus-visible:not(#_),
.kodza-sheet__close:focus-visible:not(#_) {
  outline: 2px solid var(--kz-sheet-fg);
  outline-offset: 3px;
}

.kodza-sheet__panel:not(#_) {
  position: fixed;
  display: grid;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--kz-sheet-radius);
  background: var(--kz-sheet-bg);
  box-shadow: 0 0 0 1px var(--kz-sheet-line), -20px 0 60px -20px rgba(10, 10, 10, 0.3);
  color: var(--kz-sheet-fg);
  font: inherit;
}

.kodza-sheet__panel:not([open]):not(#_) {
  display: none;
}

.kodza-sheet__panel.is-moving:not(#_) {
  transition: transform var(--kz-sheet-duration) var(--kz-sheet-ease);
}

.kodza-sheet__head:not(#_) {
  display: flex;
  padding: 20px 20px 12px 24px;
}

.kodza-sheet__title:not(#_) {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.kodza-sheet__close:not(#_) {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kz-sheet-soft);
  color: var(--kz-sheet-fg);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.kodza-sheet__close:hover:not(#_) {
  background: var(--kz-sheet-line);
}

.kodza-sheet__items:not(#_) {
  margin: 0;
  padding: 0 24px;
  list-style: none;
}

.kodza-sheet__item:not(#_) {
  display: grid;
  padding: 14px 0;
  border-bottom: 1px solid var(--kz-sheet-line);
}

.kodza-sheet__item img:not(#_) {
  border-radius: 12px;
}

.kodza-sheet__name small:not(#_) {
  font-size: 13px;
  font-weight: 400;
  color: var(--kz-sheet-muted);
}

.kodza-sheet__foot:not(#_) {
  display: grid;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--kz-sheet-line);
}

.kodza-sheet__total:not(#_) {
  display: flex;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.kodza-sheet__total b:not(#_) {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 500;
}

.kodza-sheet__note:not(#_) {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--kz-sheet-muted);
}

.kodza-sheet__cta:not(#_) {
  width: 100%;
  height: 48px;
}

@media (max-width: 640px) {
  .kodza-sheet__panel:not(#_) {
    border-radius: var(--kz-sheet-radius) var(--kz-sheet-radius) 0 0;
    box-shadow: 0 -20px 60px -20px rgba(10, 10, 10, 0.3);
  }
}

@media (max-width: 640px) {
  .kodza-sheet__head:not(#_) {
    padding-top: 4px;
  }
}

@media (max-width: 640px) {
  .kodza-sheet__foot:not(#_) {
    position: relative;
    background: var(--kz-sheet-bg);
  }
}

@media (max-width: 640px) {
  .kodza-sheet__panel.is-moving .kodza-sheet__foot:not(#_) {
    transition: transform var(--kz-sheet-duration) var(--kz-sheet-ease);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .kodza-sheet__trigger:not(#_),
  .kodza-sheet__cta: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 — Sheet
// Opens the panel as a modal dialog and slides it in; closes it with the slide (close button,
// Escape, a click on the page) and gives the focus back. On phones, the sheet can be dragged by
// its grip or its header: it rests at the half or full stop nearest to where it is let go, and
// a quick flick down (or a drag below the half stop) closes it.
(() => {
  const SELECTOR = '.kodza-sheet';
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  // The page behind stays put while it is open: a wheel or a swipe only scrolls what can
  // scroll inside, under the pointer. Listening only while open costs nothing the rest of the time.
  const holdPage = (layer, signal) => {
    const inside = (target, x, y, dy) => {
      for (let el = target; el instanceof Element && layer.contains(el); el = el.parentElement) {
        const box = el.getBoundingClientRect();
        if (x < box.left || x > box.right || y < box.top || y > box.bottom) continue;
        if (!/(auto|scroll)/.test(getComputedStyle(el).overflowY) || el.scrollHeight <= el.clientHeight + 1) continue;
        if (dy > 0 ? el.scrollTop + el.clientHeight < el.scrollHeight - 1 : el.scrollTop > 0) return true;
      }
      return false;
    };
    let last = 0;
    const wheel = (event) => !inside(event.target, event.clientX, event.clientY, event.deltaY) && event.preventDefault();
    const touchstart = (event) => (last = event.touches[0].clientY);
    const touchmove = (event) => {
      const touch = event.touches[0];
      const dy = last - touch.clientY;
      last = touch.clientY;
      if (!inside(event.target, touch.clientX, touch.clientY, dy)) event.preventDefault();
    };
    const hold = (on) => {
      const method = on ? 'addEventListener' : 'removeEventListener';
      document[method]('wheel', wheel, { passive: false });
      document[method]('touchstart', touchstart, { passive: true });
      document[method]('touchmove', touchmove, { passive: false });
    };
    const observer = new MutationObserver(() => hold(layer.open));
    observer.observe(layer, { attributes: true, attributeFilter: ['open'] });
    // Stopped while open: the page is let go
    signal.addEventListener('abort', () => {
      observer.disconnect();
      hold(false);
    });
  };

  const phone = window.matchMedia('(max-width: 640px)');
  let uid = 0;

  // One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
  function mount(root, signal) {
    const trigger = root.querySelector('.kodza-sheet__trigger');
    const panel = root.querySelector('.kodza-sheet__panel');
    holdPage(panel, signal);
    if (!trigger || !panel) return;
    const title = panel.querySelector('.kodza-sheet__title');
    if (title) {
      title.id = title.id || `kodza-sheet-${++uid}`;
      panel.setAttribute('aria-labelledby', title.id);
    }
    trigger.setAttribute('aria-haspopup', 'dialog');
    // The cascade order
    [panel.querySelector('.kodza-sheet__head'), ...panel.querySelectorAll('.kodza-sheet__item'), panel.querySelector('.kodza-sheet__foot')]
      .filter(Boolean)
      .forEach((el, i) => el.style.setProperty('--i', i));
    const duration = reduceMotion ? 0 : parseFloat(getComputedStyle(root).getPropertyValue('--kz-sheet-duration')) * 1000 || 550;
    let timer = 0;

    // The half stop: how far down the sheet rests when half open, in pixels
    const halfStop = () => Math.round(panel.offsetHeight * 0.45);
    const setY = (y) => panel.style.setProperty('--kz-sheet-y', `${Math.max(0, y)}px`);

    const open = () => {
      clearTimeout(timer);
      if (!panel.open) {
        panel.showModal();
      }
      setY(phone.matches ? halfStop() : 0);
      panel.classList.add('is-moving');
      requestAnimationFrame(() => requestAnimationFrame(() => panel.classList.add('is-open')));
      trigger.setAttribute('aria-expanded', 'true');
    };

    const close = () => {
      if (!panel.open || !panel.classList.contains('is-open')) return;
      panel.classList.add('is-moving');
      panel.classList.remove('is-open');
      trigger.setAttribute('aria-expanded', 'false');
      clearTimeout(timer);
      timer = setTimeout(() => {
        panel.close();
        panel.classList.remove('is-moving');
        trigger.focus({ preventScroll: true });
      }, duration);
    };

    trigger.addEventListener('click', open, { signal });
    panel.querySelector('.kodza-sheet__close')?.addEventListener('click', close, { signal });
    panel.addEventListener('cancel', (event) => {
      event.preventDefault();
      close();
    }, { signal });
    panel.addEventListener('click', (event) => {
      if (event.target !== panel) return;
      const box = panel.getBoundingClientRect();
      if (event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom) close();
    }, { signal });

    // Dragging the sheet on phones
    let start = null;
    const handles = [panel.querySelector('.kodza-sheet__grip'), panel.querySelector('.kodza-sheet__head')].filter(Boolean);
    handles.forEach((handle) => {
      handle.addEventListener('pointerdown', (event) => {
        if (!phone.matches || event.target.closest('button')) return;
        const y = parseFloat(getComputedStyle(panel).getPropertyValue('--kz-sheet-y')) || 0;
        start = { pointer: event.clientY, y, time: performance.now(), last: event.clientY };
        handle.setPointerCapture(event.pointerId);
        panel.classList.remove('is-moving');
      }, { signal });
      handle.addEventListener('pointermove', (event) => {
        if (!start) return;
        const dy = event.clientY - start.pointer;
        // Above the full stop, it resists like a rubber band
        const y = start.y + dy;
        setY(y < 0 ? y / 4 : y);
        start.velocity = (event.clientY - start.last) / Math.max(1, performance.now() - start.time);
        start.last = event.clientY;
        start.time = performance.now();
      }, { signal });
      const release = () => {
        if (!start) return;
        const y = parseFloat(getComputedStyle(panel).getPropertyValue('--kz-sheet-y')) || 0;
        const half = halfStop();
        const flick = (start.velocity || 0) > 0.6;
        start = null;
        panel.classList.add('is-moving');
        if (flick || y > half + panel.offsetHeight * 0.18) return close();
        setY(y < half / 2 ? 0 : half);
      };
      handle.addEventListener('pointerup', release, { signal });
      handle.addEventListener('pointercancel', release, { signal });
    });

    // Stopped while open (or closing): the dialog closes and the page scrolls again
    signal.addEventListener('abort', () => {
      clearTimeout(timer);
      if (!panel.open) return;
      panel.close();
    });
  }

  // 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).
