# Expanding Panels

> Full-height photo panels side by side: the one you hover, focus or tap widens as the others close in, its spine title slides away and rises upright with a line of text and a link. Stacked when narrow.

Image effects · image, panels, accordion, gallery, hover, expand · HTML, CSS, vanilla JS · no dependencies · updated 2026-11-05
Demo: https://kodza.dev/components/expanding-panels/
Source on GitHub: https://github.com/kodza-dev/kodza/tree/main/components/expanding-panels

## Files

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

- [`kodza-expanding-panels.css`](https://kodza.dev/registry/expanding-panels/kodza-expanding-panels.css) · 21.2 KB
- [`kodza-expanding-panels.js`](https://kodza.dev/registry/expanding-panels/kodza-expanding-panels.js) · 11.5 KB
- [`kodza-expanding-panels.html`](https://kodza.dev/registry/expanding-panels/kodza-expanding-panels.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-expanding-panels.css https://kodza.dev/registry/expanding-panels/kodza-expanding-panels.css
curl -fsSL --create-dirs -o kodza/kodza-expanding-panels.js https://kodza.dev/registry/expanding-panels/kodza-expanding-panels.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`.)

**Its images are free to use in what you ship** (Kodza house images, Kodza License). The HTML loads them from kodza.dev, whose addresses can change: copy them into the project and point each `src` to the copy (a Claude artifact embeds them instead, as Use it says).

```bash
curl -fsSL --create-dirs -o kodza/media/kz-table-1400.webp https://kodza.dev/media/kz-table-1400.webp
curl -fsSL --create-dirs -o kodza/media/kz-block-1400.webp https://kodza.dev/media/kz-block-1400.webp
curl -fsSL --create-dirs -o kodza/media/kz-columns-1400.webp https://kodza.dev/media/kz-columns-1400.webp
curl -fsSL --create-dirs -o kodza/media/kz-gap-1400.webp https://kodza.dev/media/kz-gap-1400.webp
curl -fsSL --create-dirs -o kodza/media/kz-arch-1400.webp https://kodza.dev/media/kz-arch-1400.webp
```

## API

- Root: `.kodza-expanding-panels`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-expanding-panels-height: 520px` — side by side
  - `--kz-expanding-panels-grow: 4` — the open panel, against 1 for a closed one
  - `--kz-expanding-panels-gap: 8px`
  - `--kz-expanding-panels-strip: 72px` — a closed panel, stacked (under 600px of container)
  - `--kz-expanding-panels-open-height: 380px` — the open panel, stacked
  - `--kz-expanding-panels-pad: 24px` — title and text, from the photo's edges
  - `--kz-expanding-panels-radius: calc(16px * var(--kz-radius-scale, 1))`
  - `--kz-expanding-panels-bg: #1c1c1c` — behind a photo still loading
  - `--kz-expanding-panels-fg: #ffffff`
  - `--kz-expanding-panels-muted: rgba(255, 255, 255, 0.86)`
  - `--kz-expanding-panels-veil: rgba(10, 10, 10, 0.3)` — over a closed photo
  - `--kz-expanding-panels-shade: rgba(10, 10, 10, 0.72)` — at the foot of every photo, under the text
  - `--kz-expanding-panels-link-bg: #ffffff`
  - `--kz-expanding-panels-link-fg: #0a0a0a`
  - `--kz-expanding-panels-focus: #0a0a0a`
  - `--kz-expanding-panels-line: transparent` — a hairline round each photo, for dark photos on a dark page
- 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 a panel (focus in `.kodza-expanding-panels__toggle`):
  - `ArrowLeft` / `ArrowUp`: Previous panel, opened
  - `ArrowRight` / `ArrowDown`: Next panel, opened
  - `Home` / `End`: First or last panel, opened

## Images

The shape of each image slot, measured in the demo at 1440 × 900 (desktop) and 390 × 844 (mobile). Where the shape is fixed, the frame crops the image to it: export in that shape, keep the subject near the centre, at twice the widest size shown (sharp on retina screens).

| Slot | Desktop | Mobile | Widest shown |
| --- | --- | --- | --- |
| `.kodza-expanding-panels__image` | mixed (1:1.17, 1:4.68) | mixed (1:1.11, 4.75:1) | 444 px |

## 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-expanding-panels {
    --kz-expanding-panels-bg: #1c1c1c;
    --kz-expanding-panels-focus: #f2f2f0;
    --kz-expanding-panels-line: rgba(255, 255, 255, 0.12);
  }
}
```

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

Its images have dark versions next to them (`kz-table-1400.webp` → `kz-table-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-expanding-panels.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-expanding-panels.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-expanding-panels.js`, loaded with `<script src="kodza/kodza-expanding-panels.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. A site with its own type sets it once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-font-display`, the display face (headings, big numbers, wordmarks); `--kz-font-display-weight`, its weight; `--kz-font-display-scale`, a multiplier on its sizes (1 by default); `--kz-font-display-tracking`, its letter-spacing; `--kz-font-display-case`, its case (`uppercase`…); `--kz-font-label`, the face of the small labels (meta, captions, counters, hints, footer links, button labels); `--kz-font-label-size`, their size, one for all of them (`11px`…); `--kz-font-label-weight`, their weight; `--kz-font-label-tracking`, their letter-spacing; `--kz-font-label-case`, their case (`uppercase`…; code and units keep theirs); `--kz-font-label-leading`, their line-height (`1.45`…; buttons, pills and keys keep their box); `--kz-font-mono`, the monospace face (code, labels, counters). 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">`.
- Corners: a site with its own shapes sets them once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-radius-scale` multiplies every corner (`0` square, `0.5` softer, `1` Kodza); `--kz-radius-pill` sets the pills (`0` squares them).
- Motion: a site sets its pace once for every Kodza component, on `:root`, never by editing the CSS or the JS: `--kz-motion-scale` multiplies every duration (`0.5` twice as fast, `2` twice as slow, `0` no motion at all, loops stopped, like reduced motion). Unset, nothing changes.
- 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-expanding-panels.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-expanding-panels.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">`. A site with its own type sets it once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-font-display`, the display face (headings, big numbers, wordmarks); `--kz-font-display-weight`, its weight; `--kz-font-display-scale`, a multiplier on its sizes (1 by default); `--kz-font-display-tracking`, its letter-spacing; `--kz-font-display-case`, its case (`uppercase`…); `--kz-font-label`, the face of the small labels (meta, captions, counters, hints, footer links, button labels); `--kz-font-label-size`, their size, one for all of them (`11px`…); `--kz-font-label-weight`, their weight; `--kz-font-label-tracking`, their letter-spacing; `--kz-font-label-case`, their case (`uppercase`…; code and units keep theirs); `--kz-font-label-leading`, their line-height (`1.45`…; buttons, pills and keys keep their box); `--kz-font-mono`, the monospace face (code, labels, counters).
- Corners: a site with its own shapes sets them once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-radius-scale` multiplies every corner (`0` square, `0.5` softer, `1` Kodza); `--kz-radius-pill` sets the pills (`0` squares them).
- Motion: a site sets its pace once for every Kodza component, on `:root`, never by editing the CSS or the JS: `--kz-motion-scale` multiplies every duration (`0.5` twice as fast, `2` twice as slow, `0` no motion at all, loops stopped, like reduced motion). Unset, nothing changes.
- 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.
- 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-expanding-panels', $uri . 'kodza-expanding-panels.css', [], filemtime($dir . 'kodza-expanding-panels.css'));
    wp_enqueue_script('kodza-expanding-panels', $uri . 'kodza-expanding-panels.js', [], filemtime($dir . 'kodza-expanding-panels.js'), true);
  });
  ```
  Scoped to `kodza-` classes, the CSS never touches the theme. One copy of the JS, whatever the number of blocks.
- No access to the theme files? The CSS can also go, as it is, in **Appearance → Customize → Additional CSS** (classic theme) or **Styles → Additional CSS** in the Site Editor (block theme).
- Theme with AJAX page transitions: fire `kodza:init` on the new content after each swap (and `kodza:destroy` on the old one).
- Performance plugin (WP Rocket, LiteSpeed Cache, Perfmatters…) with **Delay JavaScript execution** turned on: add `kodza` to the scripts it must not delay. Otherwise the component waits for the visitor's first scroll, tap or mouse move, and that first click can be lost.
- Colours: it takes the colour of the text around it (or keeps its own monochrome): nothing to point at the theme.
- WordPress turns straight quotes and `--` into typographic ones in the text of a Custom HTML block (not inside `<code>` or `<pre>`).

#### With Elementor

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

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

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

### Shopify

- Files: `assets/kodza-expanding-panels.css` and `assets/kodza-expanding-panels.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-expanding-panels.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-expanding-panels.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/`): `ExpandingPanels.tsx` (below), the CSS block under Code saved as `expanding-panels.css` and the JS block as `expanding-panels.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { ExpandingPanels } from '@/components/kodza/ExpandingPanels';` then `<ExpandingPanels />`. Props: `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-expanding-panels-height': … }}`), `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 './expanding-panels.css'` line there.
- Safe under StrictMode, client-side navigation and prop changes: when a prop changes, the `key` gives React a fresh element, `kodza:destroy` stops the script on the old one and `kodza:init` starts it on the new one.
- Built from your data (tabs, rows, options)? Add what the markup is made of to the `key`, as plain values (ids, text, numbers). What the visitor changes (the open tab, the sort, what they type) is the script's: follow it with `onClick` or `onInput` on the root, and change it from your code as a visitor would (click the tab; set the field's value, then dispatch a bubbling `input` event). Fields stay uncontrolled (`defaultValue`, `name`).

```tsx
'use client';
// Kodza — Expanding Panels, for React. From https://kodza.dev/components/expanding-panels/
// 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: expanding-panels.css and expanding-panels.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.
// data-kodza-manual keeps the script from starting it on its own: the effect below does, once
// React has hydrated the markup (on a page that streams in, the script can load first).
// Built from your data (tabs, rows, options)? Put what the markup is made of in the key, as plain
// values (ids, text, numbers): a change starts the script again on fresh markup. What the visitor
// changes (the open tab, the sort, what they type) is the script's: keep it out of the key, follow
// it with onClick or onInput on the root, and change it from your code as a visitor would (click
// the tab; set the field's value, then dispatch a bubbling input event).
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './expanding-panels.css';

export type ExpandingPanelsProps = Omit<ComponentPropsWithoutRef<'div'>, "children" | "vars"> & {
  /** Settings, as CSS variables on the root */
  vars?: {
    /** side by side — default: 520px */
    "--kz-expanding-panels-height"?: string | number;
    /** the open panel, against 1 for a closed one — default: 4 */
    "--kz-expanding-panels-grow"?: string | number;
    /** default: 8px */
    "--kz-expanding-panels-gap"?: string | number;
    /** a closed panel, stacked (under 600px of container) — default: 72px */
    "--kz-expanding-panels-strip"?: string | number;
    /** the open panel, stacked — default: 380px */
    "--kz-expanding-panels-open-height"?: string | number;
    /** title and text, from the photo's edges — default: 24px */
    "--kz-expanding-panels-pad"?: string | number;
    /** default: calc(16px * var(--kz-radius-scale, 1)) */
    "--kz-expanding-panels-radius"?: string | number;
    /** behind a photo still loading — default: #1c1c1c */
    "--kz-expanding-panels-bg"?: string | number;
    /** default: #ffffff */
    "--kz-expanding-panels-fg"?: string | number;
    /** default: rgba(255, 255, 255, 0.86) */
    "--kz-expanding-panels-muted"?: string | number;
    /** over a closed photo — default: rgba(10, 10, 10, 0.3) */
    "--kz-expanding-panels-veil"?: string | number;
    /** at the foot of every photo, under the text — default: rgba(10, 10, 10, 0.72) */
    "--kz-expanding-panels-shade"?: string | number;
    /** default: #ffffff */
    "--kz-expanding-panels-link-bg"?: string | number;
    /** default: #0a0a0a */
    "--kz-expanding-panels-link-fg"?: string | number;
    /** default: #0a0a0a */
    "--kz-expanding-panels-focus"?: string | number;
    /** a hairline round each photo, for dark photos on a dark page — default: transparent */
    "--kz-expanding-panels-line"?: string | number;
  };
  className?: string;
};

export function ExpandingPanels({ vars, className, style, ...rest }: ExpandingPanelsProps) {
  const ref = useRef<ComponentRef<'div'>>(null);
  const classes = ["kodza-expanding-panels", 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('./expanding-panels.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} data-kodza-manual style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <ul className="kodza-expanding-panels__list">
        <li className="kodza-expanding-panels__panel is-open">
          <div className="kodza-expanding-panels__frame">
            <img className="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-table-1400.webp" width="1400" height="1050" alt="A white table set with two glasses and a bottle, facing a misty sea with a sailboat" loading="lazy" />
            {' '}
            <button className="kodza-expanding-panels__toggle" type="button" aria-expanded="true">
              <span className="kodza-expanding-panels__spine"><span className="kodza-expanding-panels__index">01</span> Étretat</span>
            </button>
            <div className="kodza-expanding-panels__content">
              <h3 className="kodza-expanding-panels__title">Étretat</h3>
              <p className="kodza-expanding-panels__meta">Normandy · 2 guests · €140 / night</p>
              <p className="kodza-expanding-panels__text">A table, two glasses, the sea. The listing says what's in the photo.</p>
              <a className="kodza-expanding-panels__link" href="#">See the stay</a>
            </div>
          </div>
        </li>
        <li className="kodza-expanding-panels__panel">
          <div className="kodza-expanding-panels__frame">
            <img className="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-block-1400.webp" width="1120" height="1400" alt="A tall concrete slab standing alone on a bare floor" loading="lazy" />
            {' '}
            <button className="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
              <span className="kodza-expanding-panels__spine"><span className="kodza-expanding-panels__index">02</span> Alentejo</span>
            </button>
            <div className="kodza-expanding-panels__content">
              <h3 className="kodza-expanding-panels__title">Alentejo</h3>
              <p className="kodza-expanding-panels__meta">Portugal · 4 guests · €120 / night</p>
              <p className="kodza-expanding-panels__text">One wall, no neighbours. Silence is not an extra on the bill.</p>
              <a className="kodza-expanding-panels__link" href="#">See the stay</a>
            </div>
          </div>
        </li>
        <li className="kodza-expanding-panels__panel">
          <div className="kodza-expanding-panels__frame">
            <img className="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-columns-1400.webp" width="1120" height="1400" alt="A row of square concrete pillars under a flat roof, casting striped shadows" loading="lazy" />
            {' '}
            <button className="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
              <span className="kodza-expanding-panels__spine"><span className="kodza-expanding-panels__index">03</span> Seville</span>
            </button>
            <div className="kodza-expanding-panels__content">
              <h3 className="kodza-expanding-panels__title">Seville</h3>
              <p className="kodza-expanding-panels__meta">Andalusia · 6 guests · €260 / night</p>
              <p className="kodza-expanding-panels__text">Forty pillars of shade. At 4 pm, you'll want every one.</p>
              <a className="kodza-expanding-panels__link" href="#">See the stay</a>
            </div>
          </div>
        </li>
        <li className="kodza-expanding-panels__panel">
          <div className="kodza-expanding-panels__frame">
            <img className="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-gap-1400.webp" width="1400" height="583" alt="Two concrete walls with a narrow gap between them, light falling through" loading="lazy" />
            {' '}
            <button className="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
              <span className="kodza-expanding-panels__spine"><span className="kodza-expanding-panels__index">04</span> Copenhagen</span>
            </button>
            <div className="kodza-expanding-panels__content">
              <h3 className="kodza-expanding-panels__title">Copenhagen</h3>
              <p className="kodza-expanding-panels__meta">Denmark · 3 guests · €210 / night</p>
              <p className="kodza-expanding-panels__text">Two walls, one gap. The light comes through at noon, no smart bulb required.</p>
              <a className="kodza-expanding-panels__link" href="#">See the stay</a>
            </div>
          </div>
        </li>
        <li className="kodza-expanding-panels__panel">
          <div className="kodza-expanding-panels__frame">
            <img className="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-arch-1400.webp" width="1400" height="1400" alt="A concrete wall with a round-topped opening, sunlight pouring through it" loading="lazy" />
            {' '}
            <button className="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
              <span className="kodza-expanding-panels__spine"><span className="kodza-expanding-panels__index">05</span> Tangier</span>
            </button>
            <div className="kodza-expanding-panels__content">
              <h3 className="kodza-expanding-panels__title">Tangier</h3>
              <p className="kodza-expanding-panels__meta">Morocco · 4 guests · €190 / night</p>
              <p className="kodza-expanding-panels__text">One arch, facing west. Sunset included, no upgrade needed.</p>
              <a className="kodza-expanding-panels__link" href="#">See the stay</a>
            </div>
          </div>
        </li>
      </ul>
    </div>
  );
}
```

## Code

```html
<div class="kodza-expanding-panels">
  <ul class="kodza-expanding-panels__list">
    <li class="kodza-expanding-panels__panel is-open">
      <div class="kodza-expanding-panels__frame">
        <img class="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-table-1400.webp" width="1400" height="1050" alt="A white table set with two glasses and a bottle, facing a misty sea with a sailboat" loading="lazy">
        <button class="kodza-expanding-panels__toggle" type="button" aria-expanded="true">
          <span class="kodza-expanding-panels__spine"><span class="kodza-expanding-panels__index">01</span> Étretat</span>
        </button>
        <div class="kodza-expanding-panels__content">
          <h3 class="kodza-expanding-panels__title">Étretat</h3>
          <p class="kodza-expanding-panels__meta">Normandy · 2&nbsp;guests · €140&nbsp;/&nbsp;night</p>
          <p class="kodza-expanding-panels__text">A table, two glasses, the sea. The listing says what's in the photo.</p>
          <a class="kodza-expanding-panels__link" href="#">See the stay</a>
        </div>
      </div>
    </li>
    <li class="kodza-expanding-panels__panel">
      <div class="kodza-expanding-panels__frame">
        <img class="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-block-1400.webp" width="1120" height="1400" alt="A tall concrete slab standing alone on a bare floor" loading="lazy">
        <button class="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
          <span class="kodza-expanding-panels__spine"><span class="kodza-expanding-panels__index">02</span> Alentejo</span>
        </button>
        <div class="kodza-expanding-panels__content">
          <h3 class="kodza-expanding-panels__title">Alentejo</h3>
          <p class="kodza-expanding-panels__meta">Portugal · 4&nbsp;guests · €120&nbsp;/&nbsp;night</p>
          <p class="kodza-expanding-panels__text">One wall, no neighbours. Silence is not an extra on the bill.</p>
          <a class="kodza-expanding-panels__link" href="#">See the stay</a>
        </div>
      </div>
    </li>
    <li class="kodza-expanding-panels__panel">
      <div class="kodza-expanding-panels__frame">
        <img class="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-columns-1400.webp" width="1120" height="1400" alt="A row of square concrete pillars under a flat roof, casting striped shadows" loading="lazy">
        <button class="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
          <span class="kodza-expanding-panels__spine"><span class="kodza-expanding-panels__index">03</span> Seville</span>
        </button>
        <div class="kodza-expanding-panels__content">
          <h3 class="kodza-expanding-panels__title">Seville</h3>
          <p class="kodza-expanding-panels__meta">Andalusia · 6&nbsp;guests · €260&nbsp;/&nbsp;night</p>
          <p class="kodza-expanding-panels__text">Forty pillars of shade. At 4&nbsp;pm, you'll want every one.</p>
          <a class="kodza-expanding-panels__link" href="#">See the stay</a>
        </div>
      </div>
    </li>
    <li class="kodza-expanding-panels__panel">
      <div class="kodza-expanding-panels__frame">
        <img class="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-gap-1400.webp" width="1400" height="583" alt="Two concrete walls with a narrow gap between them, light falling through" loading="lazy">
        <button class="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
          <span class="kodza-expanding-panels__spine"><span class="kodza-expanding-panels__index">04</span> Copenhagen</span>
        </button>
        <div class="kodza-expanding-panels__content">
          <h3 class="kodza-expanding-panels__title">Copenhagen</h3>
          <p class="kodza-expanding-panels__meta">Denmark · 3&nbsp;guests · €210&nbsp;/&nbsp;night</p>
          <p class="kodza-expanding-panels__text">Two walls, one gap. The light comes through at noon, no smart bulb required.</p>
          <a class="kodza-expanding-panels__link" href="#">See the stay</a>
        </div>
      </div>
    </li>
    <li class="kodza-expanding-panels__panel">
      <div class="kodza-expanding-panels__frame">
        <img class="kodza-expanding-panels__image" src="https://kodza.dev/media/kz-arch-1400.webp" width="1400" height="1400" alt="A concrete wall with a round-topped opening, sunlight pouring through it" loading="lazy">
        <button class="kodza-expanding-panels__toggle" type="button" aria-expanded="false">
          <span class="kodza-expanding-panels__spine"><span class="kodza-expanding-panels__index">05</span> Tangier</span>
        </button>
        <div class="kodza-expanding-panels__content">
          <h3 class="kodza-expanding-panels__title">Tangier</h3>
          <p class="kodza-expanding-panels__meta">Morocco · 4&nbsp;guests · €190&nbsp;/&nbsp;night</p>
          <p class="kodza-expanding-panels__text">One arch, facing west. Sunset included, no upgrade needed.</p>
          <a class="kodza-expanding-panels__link" href="#">See the stay</a>
        </div>
      </div>
    </li>
  </ul>
</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 — Expanding Panels
   Full-height photo panels side by side, one open at a time: hover or focus one and it widens
   while the others close in, each photo recropped, never stretched. The title lying on its
   spine slides away as the same title rises upright from its mask, with a line of text and a
   link. Stacked in narrow containers: the open panel grows in height.
   Tuned with the --kz-expanding-panels-* variables; the script's timing sits under its SELECTOR. */
.kodza-expanding-panels {
  --kz-expanding-panels-height: 520px; /* side by side */
  --kz-expanding-panels-grow: 4; /* the open panel, against 1 for a closed one */
  --kz-expanding-panels-gap: 8px;
  --kz-expanding-panels-strip: 72px; /* a closed panel, stacked (under 600px of container) */
  --kz-expanding-panels-open-height: 380px; /* the open panel, stacked */
  --kz-expanding-panels-pad: 24px; /* title and text, from the photo's edges */
  --kz-expanding-panels-radius: calc(16px * var(--kz-radius-scale, 1));
  --kz-expanding-panels-bg: #1c1c1c; /* behind a photo still loading */
  --kz-expanding-panels-fg: #ffffff;
  --kz-expanding-panels-muted: rgba(255, 255, 255, 0.86);
  --kz-expanding-panels-veil: rgba(10, 10, 10, 0.3); /* over a closed photo */
  --kz-expanding-panels-shade: rgba(10, 10, 10, 0.72); /* at the foot of every photo, under the text */
  --kz-expanding-panels-link-bg: #ffffff;
  --kz-expanding-panels-link-fg: #0a0a0a;
  --kz-expanding-panels-focus: #0a0a0a;
  --kz-expanding-panels-line: transparent; /* a hairline round each photo, for dark photos on a dark page */

  container: kodza-expanding-panels / inline-size;
}

.kodza-expanding-panels__list {
  display: flex;
  gap: var(--kz-expanding-panels-gap);
  height: var(--kz-expanding-panels-height);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The panel holds the place; only its frame takes the pointer, so a panel that slides under
   a resting pointer never opens by itself */
.kodza-expanding-panels__panel {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.kodza-expanding-panels__panel.is-open {
  flex-grow: var(--kz-expanding-panels-grow);
}

/* The script slides and resizes the frame from its old place to its new one */
.kodza-expanding-panels__frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--kz-expanding-panels-radius);
  background: var(--kz-expanding-panels-bg);
  pointer-events: auto;
}

.kodza-expanding-panels__frame:has(.kodza-expanding-panels__toggle:focus-visible) {
  outline: 2px solid var(--kz-expanding-panels-focus);
  outline-offset: 3px;
}

.kodza-expanding-panels__image {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
}

/* The veil darkens the closed photos and lifts off the open one; the shade keeps the text
   readable at the foot of every photo */
.kodza-expanding-panels__frame::before,
.kodza-expanding-panels__frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.kodza-expanding-panels__frame::before {
  background: var(--kz-expanding-panels-veil);
  transition: opacity calc(0.5s * var(--kz-motion-scale, 1)) ease;
}

.kodza-expanding-panels__frame::after {
  border-radius: inherit;
  background: linear-gradient(to top, var(--kz-expanding-panels-shade), var(--kz-expanding-panels-shade) 22%, transparent 78%);
  box-shadow: inset 0 0 0 1px var(--kz-expanding-panels-line);
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__frame::before {
  opacity: 0;
}

/* The button covers the whole photo: hover, focus or tap it to open the panel */
.kodza-expanding-panels__toggle {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--kz-expanding-panels-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.kodza-expanding-panels__toggle:focus-visible {
  outline: none;
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__toggle {
  cursor: default;
}

/* The title on the spine, read bottom to top like the back of a book. Opening, it slides out
   past the photo's edge; closing, it comes back once the panel has closed in */
.kodza-expanding-panels__spine {
  position: absolute;
  bottom: var(--kz-expanding-panels-pad);
  left: var(--kz-expanding-panels-pad);
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--kz-font-display, inherit);
  font-size: calc(20px * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 500);
  letter-spacing: var(--kz-font-display-tracking, -0.02em);
  text-transform: var(--kz-font-display-case, inherit);
  line-height: 1;
  white-space: nowrap;
  transition:
    translate calc(0.5s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1) calc(0.2s * var(--kz-motion-scale, 1)),
    opacity 0s linear calc(0.2s * var(--kz-motion-scale, 1));
}

.kodza-expanding-panels__index {
  margin-bottom: 4px;
  color: var(--kz-expanding-panels-muted);
  font-family: var(--kz-font-label, var(--kz-font-mono, ui-monospace, "SF Mono", Menlo, monospace));
  font-size: var(--kz-font-label-size, 11px);
  font-weight: var(--kz-font-label-weight, 400);
  letter-spacing: var(--kz-font-label-tracking, 0);
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__spine {
  translate: calc(-100% - var(--kz-expanding-panels-pad) - 4px) 0;
  opacity: 0;
  transition:
    translate calc(0.35s * var(--kz-motion-scale, 1)) cubic-bezier(0.65, 0, 0.35, 1),
    opacity 0s linear calc(0.35s * var(--kz-motion-scale, 1));
}

/* The text, as wide as an open panel (--kz-expanding-panels-open, measured by the script):
   it never rewraps while the panel grows, the panel's edge uncovers it */
.kodza-expanding-panels__content {
  position: absolute;
  bottom: var(--kz-expanding-panels-pad);
  left: var(--kz-expanding-panels-pad);
  z-index: 2;
  width: calc(var(--kz-expanding-panels-open, 100%) - 2 * var(--kz-expanding-panels-pad));
  box-sizing: border-box;
  color: var(--kz-expanding-panels-fg);
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear calc(0.2s * var(--kz-motion-scale, 1));
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__content {
  visibility: visible;
  transition-delay: 0s;
}

/* Each block rises from behind its own mask, one after the other (the clip moves with it:
   together they show the block's final box only) */
.kodza-expanding-panels__content > * {
  transform: translateY(100%);
  clip-path: inset(-10px -20px 100% -20px);
  transition:
    transform calc(0.18s * var(--kz-motion-scale, 1)) cubic-bezier(0.65, 0, 0.35, 1),
    clip-path calc(0.18s * var(--kz-motion-scale, 1)) cubic-bezier(0.65, 0, 0.35, 1);
}

.kodza-expanding-panels__content > :nth-child(2) {
  --kz-expanding-panels-step: 1;
}

.kodza-expanding-panels__content > :nth-child(3) {
  --kz-expanding-panels-step: 2;
}

.kodza-expanding-panels__content > :nth-child(4) {
  --kz-expanding-panels-step: 3;
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__content > * {
  transform: none;
  clip-path: inset(-10px -20px -10px -20px);
  transition:
    transform calc(0.6s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1) calc((0.3s + var(--kz-expanding-panels-step, 0) * 0.07s) * var(--kz-motion-scale, 1)),
    clip-path calc(0.6s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1) calc((0.3s + var(--kz-expanding-panels-step, 0) * 0.07s) * var(--kz-motion-scale, 1));
}

.kodza-expanding-panels__title {
  margin: 0 0 8px;
  color: inherit;
  font-family: var(--kz-font-display, inherit);
  font-size: calc(30px * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 600);
  letter-spacing: var(--kz-font-display-tracking, -0.035em);
  text-transform: var(--kz-font-display-case, inherit);
  line-height: 1.1;
}

.kodza-expanding-panels__meta {
  margin: 0 0 12px;
  color: var(--kz-expanding-panels-muted);
  font-family: var(--kz-font-label, var(--kz-font-mono, ui-monospace, "SF Mono", Menlo, monospace));
  font-size: var(--kz-font-label-size, 12px);
  font-weight: var(--kz-font-label-weight, inherit);
  letter-spacing: var(--kz-font-label-tracking, inherit);
  line-height: var(--kz-font-label-leading, 1.4);
}

.kodza-expanding-panels__text {
  max-width: 36ch;
  margin: 0 0 18px;
  color: var(--kz-expanding-panels-muted);
  font-size: 15px;
  line-height: 1.5;
  text-wrap: pretty;
}

.kodza-expanding-panels__link {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 18px;
  box-sizing: border-box;
  border-radius: var(--kz-radius-pill, 999px);
  background: var(--kz-expanding-panels-link-bg);
  color: var(--kz-expanding-panels-link-fg);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 14px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, inherit);
  text-transform: var(--kz-font-label-case, inherit);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

/* A drawn chevron, nudged on hover */
.kodza-expanding-panels__link::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 9px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform calc(0.2s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1);
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__link {
  pointer-events: auto;
}

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

@media (hover: hover) {
  .kodza-expanding-panels__link:hover::after {
    transform: translateX(3px) rotate(45deg);
  }
}

/* Stacked: the panels pile up and the open one grows in height; the title lies flat */
@container kodza-expanding-panels (max-width: 599px) {
  .kodza-expanding-panels__list {
    flex-direction: column;
    height: auto;
  }

  .kodza-expanding-panels__panel {
    flex: none;
    height: var(--kz-expanding-panels-strip);
  }

  .kodza-expanding-panels__panel.is-open {
    height: var(--kz-expanding-panels-open-height);
  }

  .kodza-expanding-panels__spine {
    top: calc(var(--kz-expanding-panels-strip) / 2);
    bottom: auto;
    writing-mode: horizontal-tb;
    transform: translateY(-50%);
  }

  .kodza-expanding-panels__index {
    margin: 0 4px 0 0;
  }

  .kodza-expanding-panels__panel.is-open .kodza-expanding-panels__spine {
    translate: 0 calc(-1 * var(--kz-expanding-panels-strip));
  }

  .kodza-expanding-panels__text {
    margin-bottom: 16px;
  }

  /* The text climbs higher on a short, wide photo: so does the shade */
  .kodza-expanding-panels__frame::after {
    background: linear-gradient(to top, var(--kz-expanding-panels-shade), var(--kz-expanding-panels-shade) 34%, transparent 92%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-expanding-panels__frame::before,
  .kodza-expanding-panels__spine,
  .kodza-expanding-panels__content,
  .kodza-expanding-panels__content > *,
  .kodza-expanding-panels__link::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* Theming example — on a dark background:
.dark-section .kodza-expanding-panels {
  --kz-expanding-panels-bg: #1c1c1c;
  --kz-expanding-panels-focus: #f2f2f0;
}
*/

/* kodza-guard 80180f194deb — 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-expanding-panels__toggle):not(#_) {
  outline: revert;
}

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

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

.kodza-expanding-panels:not(#_),
.kodza-expanding-panels__frame:not(#_),
.kodza-expanding-panels__spine:not(#_),
.kodza-expanding-panels__index:not(#_) {
  box-sizing: revert;
}

.kodza-expanding-panels__list: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-expanding-panels__panel:not(#_) {
  border: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-expanding-panels__image: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-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-expanding-panels__toggle:not(#_) {
  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;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  white-space: revert;
  min-height: revert;
}

.kodza-expanding-panels__title:not(#_) {
  border: 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;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-expanding-panels__meta:not(#_) {
  border: 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;
  font-style: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-expanding-panels__text:not(#_) {
  border: 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-height: revert;
  font-family: revert;
  font-weight: revert;
  font-style: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-expanding-panels__link:not(#_) {
  border: revert;
  margin: revert;
  list-style: revert;
  float: revert;
  position: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-expanding-panels__panel:not(#_):where(:not([hidden])),
.kodza-expanding-panels__title:not(#_):where(:not([hidden])),
.kodza-expanding-panels__meta:not(#_):where(:not([hidden])),
.kodza-expanding-panels__text:not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-expanding-panels__panel:not(#_):where([hidden]),
.kodza-expanding-panels__title:not(#_):where([hidden]),
.kodza-expanding-panels__meta:not(#_):where([hidden]),
.kodza-expanding-panels__text:not(#_):where([hidden]) {
  display: none;
}

.kodza-expanding-panels__frame:not(#_)::before,
.kodza-expanding-panels__frame:not(#_)::after,
.kodza-expanding-panels__link:not(#_)::after {
  box-sizing: revert;
}

/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */

.kodza-expanding-panels__list:not(#_) {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kodza-expanding-panels__panel:not(#_) {
  position: relative;
  margin: 0;
  padding: 0;
}

.kodza-expanding-panels__image:not(#_) {
  display: block;
  max-width: none;
}

.kodza-expanding-panels__toggle:not(#_) {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--kz-expanding-panels-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.kodza-expanding-panels__toggle:focus-visible:not(#_) {
  outline: none;
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__toggle:not(#_) {
  cursor: default;
}

.kodza-expanding-panels__content > *:not(#_) {
  transition: transform calc(0.18s * var(--kz-motion-scale, 1)) cubic-bezier(0.65, 0, 0.35, 1),
    clip-path calc(0.18s * var(--kz-motion-scale, 1)) cubic-bezier(0.65, 0, 0.35, 1);
}

.kodza-expanding-panels__panel.is-open .kodza-expanding-panels__content > *:not(#_) {
  transition: transform calc(0.6s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1) calc((0.3s + var(--kz-expanding-panels-step, 0) * 0.07s) * var(--kz-motion-scale, 1)),
    clip-path calc(0.6s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1) calc((0.3s + var(--kz-expanding-panels-step, 0) * 0.07s) * var(--kz-motion-scale, 1));
}

.kodza-expanding-panels__title:not(#_) {
  margin: 0 0 8px;
  color: inherit;
  font-family: var(--kz-font-display, inherit);
  font-size: calc(30px * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 600);
  letter-spacing: var(--kz-font-display-tracking, -0.035em);
  text-transform: var(--kz-font-display-case, inherit);
  line-height: 1.1;
}

.kodza-expanding-panels__meta:not(#_) {
  margin: 0 0 12px;
  color: var(--kz-expanding-panels-muted);
  font-family: var(--kz-font-label, var(--kz-font-mono, ui-monospace, "SF Mono", Menlo, monospace));
  font-size: var(--kz-font-label-size, 12px);
  font-weight: var(--kz-font-label-weight, inherit);
  letter-spacing: var(--kz-font-label-tracking, inherit);
  line-height: var(--kz-font-label-leading, 1.4);
}

.kodza-expanding-panels__text:not(#_) {
  max-width: 36ch;
  margin: 0 0 18px;
  color: var(--kz-expanding-panels-muted);
  font-size: 15px;
  line-height: 1.5;
}

.kodza-expanding-panels__link:not(#_) {
  display: inline-flex;
  padding: 0 18px;
  box-sizing: border-box;
  border-radius: var(--kz-radius-pill, 999px);
  background: var(--kz-expanding-panels-link-bg);
  color: var(--kz-expanding-panels-link-fg);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 14px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, inherit);
  text-transform: var(--kz-font-label-case, inherit);
  line-height: 1;
  text-decoration: none;
}

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

@container kodza-expanding-panels (max-width: 599px) {
  .kodza-expanding-panels__text:not(#_) {
    margin-bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-expanding-panels__content > *:not(#_) {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !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 — Expanding Panels
// Opens one panel at a time, on hover (after a short rest, so a pointer passing through opens
// nothing), focus or tap: the panels slide and resize from where they were to where they are
// (the Make Way engine, measured before and after), the photos recropped as they go. The text
// keeps the open panel's width all along, so it never rewraps while the panel grows.
// Tune it with the --kz-expanding-panels-* variables in the CSS and the constants below.
(() => {
  const SELECTOR = '.kodza-expanding-panels';
  const MOVE = 750; // ms, the panels sliding to their new widths; the text rises while they move (CSS)
  const MOVE_EASE = 'cubic-bezier(0.65, 0, 0.35, 1)';
  const CAUGHT_EASE = 'cubic-bezier(0.33, 0.66, 0.4, 1)'; // a move caught mid-way goes on at speed, no stop
  const HOVER_REST = 90; // ms the pointer rests on a panel before it opens (a wait, not motion: the pace leaves it)
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  // The site's pace, --kz-motion-scale (set on :root, read on the instance): every duration of the
  // script times it, and 0 moves nothing, like reduced motion
  const paceOf = (el) => {
    const pace = parseFloat(getComputedStyle(el).getPropertyValue('--kz-motion-scale'));
    return pace >= 0 ? pace : 1;
  };

  // One instance, with its own state: two copies on a page never interfere. Everything it
  // starts is tied to `signal` (listeners get { signal }, observers and timers stop on its
  // 'abort' event), so kodza:destroy stops it all.
  function mount(root, signal) {
    const pace = paceOf(root);
    const still = reduceMotion || !pace; // the still path: no motion asked, by the visitor or the site
    const list = root.querySelector('.kodza-expanding-panels__list');
    const panels = list ? [...list.children].filter((el) => el.matches('.kodza-expanding-panels__panel')) : [];
    const frames = panels.map((panel) => panel.querySelector('.kodza-expanding-panels__frame'));
    const toggles = panels.map((panel) => panel.querySelector('.kodza-expanding-panels__toggle'));
    if (panels.length < 2 || [...frames, ...toggles].some((el) => !el)) return;

    // The text's width: an open panel's, so it is laid out once and only uncovered as it opens
    let current = 0;
    const measure = () => root.style.setProperty('--kz-expanding-panels-open', `${panels[current].offsetWidth}px`);

    // The engine moves the panels: they slide and resize from their old widths to their new ones
    const engine = makeWay(list, frames, { duration: MOVE * pace, easing: MOVE_EASE, caught: CAUGHT_EASE });
    const set = (next) => {
      panels.forEach((panel, i) => {
        panel.classList.toggle('is-open', i === next);
        toggles[i].setAttribute('aria-expanded', String(i === next));
      });
      current = next;
      measure();
    };
    const open = (next) => {
      if (next === current) return;
      if (still) set(next);
      else engine.move(() => set(next));
    };

    // Hover opens after a short rest, with a mouse or a pen only: a finger taps
    const canHover = window.matchMedia('(hover: hover)');
    let timer = 0;
    frames.forEach((frame, i) => {
      frame.addEventListener('pointerenter', (event) => {
        if (event.pointerType === 'touch' || !canHover.matches) return;
        clearTimeout(timer);
        timer = setTimeout(() => open(i), HOVER_REST);
      }, { signal });
      frame.addEventListener('pointerleave', () => clearTimeout(timer), { signal });
    });
    toggles.forEach((toggle, i) => {
      toggle.addEventListener('click', () => open(i), { signal });
      // From the keyboard only: a click opens on its own, and a window coming back to the front
      // must not reopen the panel that kept the focus
      toggle.addEventListener('focus', () => toggle.matches(':focus-visible') && open(i), { signal });
    });

    // The arrows move along the panels, and the panel that takes the focus opens
    root.addEventListener('keydown', (event) => {
      const at = toggles.indexOf(event.target);
      const to = at < 0 ? undefined : { ArrowLeft: at - 1, ArrowUp: at - 1, ArrowRight: at + 1, ArrowDown: at + 1, Home: 0, End: toggles.length - 1 }[event.key];
      if (to === undefined) return;
      event.preventDefault();
      toggles[(to + toggles.length) % toggles.length].focus();
    }, { signal });

    // Written open in the markup: it starts open (the first one otherwise)
    set(Math.max(0, panels.findIndex((panel) => panel.classList.contains('is-open'))));

    // A new width changes an open panel's width, so the text's
    let width = list.clientWidth;
    let raf = 0;
    const observer = new ResizeObserver(() => {
      if (list.clientWidth === width) return;
      width = list.clientWidth;
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => {
        engine.cancel();
        measure();
      });
    });
    observer.observe(root);
    signal.addEventListener('abort', () => {
      observer.disconnect();
      cancelAnimationFrame(raf);
      clearTimeout(timer);
      engine.cancel();
    });
  }

  // ---------- Make Way engine (copied as is by Expanding Panels) ----------
  // move(change) measures every frame in the container's own pixels (a parent scaled by
  // transform does not shift them), runs change() to give them their new places, measures again,
  // then slides and resizes each frame from where it was to where it is. Caught mid-move, a frame
  // starts again from where it is. The container's height follows, so the page below never
  // jumps. A frame clips its picture (object-fit: cover): the picture grows with it, never stretched.
  // timing: { duration, easing, caught } — caught, the easing of a move that starts mid-way.
  function makeWay(container, frames, { duration, easing, caught = easing }) {
    let moving = [];
    const rects = () => {
      const box = container.getBoundingClientRect();
      const scale = box.width / container.offsetWidth || 1;
      return frames.map((frame) => {
        const rect = frame.getBoundingClientRect();
        return { x: (rect.left - box.left) / scale, y: (rect.top - box.top) / scale, w: rect.width / scale, h: rect.height / scale };
      });
    };
    const cancel = () => {
      moving.forEach((animation) => animation.cancel());
      moving = [];
    };
    const move = (change) => {
      const before = rects();
      const tall = container.offsetHeight;
      const timing = { duration, easing: moving.some((a) => a.playState === 'running') ? caught : easing };
      cancel();
      change();
      const after = rects();
      frames.forEach((frame, i) => {
        const [a, b] = [before[i], after[i]];
        if (Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.w - b.w), Math.abs(a.h - b.h)) < 0.5) return;
        moving.push(frame.animate([
          { transform: `translate(${a.x - b.x}px, ${a.y - b.y}px)`, width: `${a.w}px`, height: `${a.h}px` },
          { transform: 'translate(0px, 0px)', width: `${b.w}px`, height: `${b.h}px` },
        ], timing));
      });
      const height = container.offsetHeight;
      if (height !== tall) moving.push(container.animate([{ height: `${tall}px` }, { height: `${height}px` }], timing));
      // Resolves once everything has arrived, false when a newer move or a cancel cut it short
      return Promise.all(moving.map((animation) => animation.finished)).then(() => true, () => false);
    };
    return { move, cancel };
  }
  // ---------- end of the engine ----------

  // Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
  // event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
  // markup back. For themes and apps that swap content without a page load. Each running root
  // keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
  // component inside another one is saved as written, not half-started, and stopped with it. Two
  // components on one root (a reveal on a stat card) both start, and stop together.
  const KODZA = Symbol.for('kodza');
  const RUNNING = Symbol.for(`kodza ${SELECTOR}`); // a root this component runs on, for every copy of this script
  const instances = new WeakMap();
  const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
  const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
  const put = (el, saved) => {
    [...el.attributes].forEach((a) => el.removeAttribute(a.name));
    saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
    el.innerHTML = saved.html;
  };
  // The markup inside a root as written: Kodza components already running in it give back their own
  const written = (root) => {
    const all = [...root.querySelectorAll('*')];
    if (!all.some((el) => el[KODZA])) return root.innerHTML;
    const copy = root.cloneNode(true);
    const twins = copy.querySelectorAll('*');
    let last = null;
    all.forEach((el, i) => {
      if (!el[KODZA] || last?.contains(el)) return;
      last = el;
      put(twins[i], el[KODZA]);
    });
    return copy.innerHTML;
  };
  const init = (scope) => find(scope).forEach((root) => {
    // Already running, maybe from another copy of this script. Marked is-ready with no Kodza component
    // running on it, a root is a copy of a started one (a cloned slide): it is left as it is
    if (root[RUNNING] || (root.classList.contains('is-ready') && !root[KODZA])) return;
    // Rendered by React (data-kodza-manual): React starts it, with an init aimed at that markup once
    // it has hydrated it. Any earlier start would change markup React has not taken over yet
    const owner = root.closest('[data-kodza-manual]');
    if (owner && !(scope && owner.contains(scope))) return;
    const controller = new AbortController();
    // Another Kodza component already running on this root: its markup as written is kept, and the
    // two stop together
    const before = root[KODZA];
    const saved = { html: before ? before.html : written(root), attrs: before ? before.attrs : attrsOf(root), stop: () => destroy(root) };
    if (before) before.above = saved;
    instances.set(root, { controller, saved, before });
    root[KODZA] = saved;
    root[RUNNING] = true;
    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.saved.above?.stop(); // a Kodza component started after it on the same root stops first
    // The Kodza components running inside it stop first: once its markup is put back, their own
    // script could not find them any more
    root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
    instance.controller.abort();
    delete root[RUNNING];
    // Started on top of another one: that one stops next, and puts the markup back
    if (instance.before) {
      delete instance.before.above;
      root[KODZA] = instance.before;
      return instance.before.stop();
    }
    delete root[KODZA];
    put(root, instance.saved);
  });
  document.addEventListener('kodza:init', (event) => init(event.detail?.root));
  document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
  init();
  // Loaded in <head>, the script runs before the markup exists: once more when it is parsed
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
```

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