# Scroll Down

> The cue at the bottom of a hero: an arrow in a ring or a mouse whose wheel rolls now and then. One click glides to the next section, the first scroll fades it out, and it comes back at the top.

Buttons · scroll, button, hero, arrow, mouse, indicator · HTML, CSS, vanilla JS · no dependencies · updated 2026-10-26
Demo: https://kodza.dev/components/scroll-down/

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-scroll-down.css`](https://kodza.dev/registry/scroll-down/kodza-scroll-down.css) · 8.3 KB
- [`kodza-scroll-down.js`](https://kodza.dev/registry/scroll-down/kodza-scroll-down.js) · 11.5 KB
- [`kodza-scroll-down.html`](https://kodza.dev/registry/scroll-down/kodza-scroll-down.html) · 0.5 KB · the markup, to adapt and paste into your page

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

```bash
curl -fsSL --create-dirs -o kodza/kodza-scroll-down.css https://kodza.dev/registry/scroll-down/kodza-scroll-down.css
curl -fsSL --create-dirs -o kodza/kodza-scroll-down.js https://kodza.dev/registry/scroll-down/kodza-scroll-down.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-scroll-down`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-scroll-down-ink: #0a0a0a`
  - `--kz-scroll-down-paper: #ffffff`
  - `--kz-scroll-down-line: rgba(10, 10, 10, 0.28)`
  - `--kz-scroll-down-size: 52px`
  - `--kz-scroll-down-travel: 36px`
  - `--kz-scroll-down-ease: cubic-bezier(0.22, 1, 0.36, 1)`
- Modifiers: `.kodza-scroll-down--mouse`
- Attributes:
  - `data-hide`
  - `data-target`
- 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 cue (focus in `.kodza-scroll-down`):
  - `Enter` / `Space`: Glides to the next section and moves the focus there

## 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-scroll-down {
    --kz-scroll-down-ink: #f2f2f0;
    --kz-scroll-down-paper: #0a0a0a;
    --kz-scroll-down-line: rgba(255, 255, 255, 0.34);
  }
}
```

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

## Use it

### Plain HTML page

- CSS: `kodza/kodza-scroll-down.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-scroll-down.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-scroll-down.js`, loaded with `<script src="kodza/kodza-scroll-down.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-scroll-down.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-scroll-down.js' -e 'd' -e '}' page.html > artifact.html`.
- Font: load Geist from Google Fonts (allowed): `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`.
- Dark mode: the viewer sets `data-theme="dark"` or `"light"` on `<html>`, or nothing when it follows the system. Write the Dark mode rules twice: inside `@media (prefers-color-scheme: dark)` with `:root:not([data-theme="light"])` in front of each selector, and with `:root[data-theme="dark"]` in front of each selector.

### WordPress

- HTML: a **Custom HTML** block (or a pattern / template part). WordPress keeps this markup as it is only for users allowed to post unfiltered HTML (Administrators; Super Admins on multisite): for anyone else it strips tags such as `<svg>`, `<input>` or `<dialog>`, so add it from the theme (a pattern or template part) instead.
- This one is inline (it flows like a word): pasted alone, many themes leave it at the edge of the page (block themes, and classic ones like Twenty Twenty-One or Blocksy), so put the Custom HTML block inside a **Group** block to line it up with the text.
- CSS and JS: the downloaded files go in the theme, under `wp-content/themes/<your-theme>/kodza/` (the child theme if there is one), enqueued from its functions.php (or a code-snippets plugin):
  ```php
  add_action('wp_enqueue_scripts', function () {
    $dir = get_stylesheet_directory() . '/kodza/';
    $uri = get_stylesheet_directory_uri() . '/kodza/';
    wp_enqueue_style('kodza-scroll-down', $uri . 'kodza-scroll-down.css', [], filemtime($dir . 'kodza-scroll-down.css'));
    wp_enqueue_script('kodza-scroll-down', $uri . 'kodza-scroll-down.js', [], filemtime($dir . 'kodza-scroll-down.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. This one reads the page around it, and a script in the widget runs before the rest of the page exists: put its `<script>` in an HTML widget at the bottom of the page instead.

### Shopify

- Files: `assets/kodza-scroll-down.css` and `assets/kodza-scroll-down.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-scroll-down.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-scroll-down.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/`): `ScrollDown.tsx` (below), the CSS block under Code saved as `scroll-down.css` and the JS block as `scroll-down.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { ScrollDown } from '@/components/kodza/ScrollDown';` then `<ScrollDown />`. Props: `variant` ("mouse", or several in an array), `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-scroll-down-ink': … }}`), `className`, `style` and the other props of its `<button>` (`onClick`, `aria-…`).
- Next.js App Router: it is a Client Component already (`'use client'`). Pages Router: Next.js takes global CSS only in `pages/_app`, so move the `import './scroll-down.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 — Scroll Down, for React. From https://kodza.dev/components/scroll-down/
// 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: scroll-down.css and scroll-down.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
// Built from your data (tabs, rows, options)? Put what the markup is made of in the key, as plain
// values (ids, text, numbers): a change starts the script again on fresh markup. What the visitor
// changes (the open tab, the sort, what they type) is the script's: keep it out of the key, follow
// it with onClick or onInput on the root, and change it from your code as a visitor would (click
// the tab; set the field's value, then dispatch a bubbling input event).
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './scroll-down.css';

type Variant = "mouse";

export type ScrollDownProps = Omit<ComponentPropsWithoutRef<'button'>, "children" | "variant" | "vars"> & {
  /** Modifier class(es): .kodza-scroll-down--mouse */
  variant?: Variant | Variant[];
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #0a0a0a */
    "--kz-scroll-down-ink"?: string | number;
    /** default: #ffffff */
    "--kz-scroll-down-paper"?: string | number;
    /** default: rgba(10, 10, 10, 0.28) */
    "--kz-scroll-down-line"?: string | number;
    /** default: 52px */
    "--kz-scroll-down-size"?: string | number;
    /** default: 36px */
    "--kz-scroll-down-travel"?: string | number;
    /** default: cubic-bezier(0.22, 1, 0.36, 1) */
    "--kz-scroll-down-ease"?: string | number;
  };
  className?: string;
};

export function ScrollDown({ variant, vars, className, style, ...rest }: ScrollDownProps) {
  const ref = useRef<ComponentRef<'button'>>(null);
  const classes = ["kodza-scroll-down", ...([] as string[]).concat(variant ?? []).map((v) => `kodza-scroll-down--${v}`), className].filter(Boolean).join(' ');
  // Everything the markup is made of: when it changes, React gets a fresh element (see the top)
  const key = JSON.stringify([classes, 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('./scroll-down.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 (
    <button type="button" aria-label="Scroll to the next section" key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <span className="kodza-scroll-down__icon" aria-hidden="true">
        <svg viewBox="0 0 18 18">
          <path d="M9 2.75v12.5M4 10.25l5 5 5-5" />
        </svg>
      </span>
    </button>
  );
}
```

## Code

```html
<button class="kodza-scroll-down" type="button" aria-label="Scroll to the next section">
  <span class="kodza-scroll-down__icon" aria-hidden="true">
    <svg viewBox="0 0 18 18"><path d="M9 2.75v12.5M4 10.25l5 5 5-5" /></svg>
  </span>
</button>

<button class="kodza-scroll-down kodza-scroll-down--mouse" type="button" aria-label="Scroll to the next section">
  <span class="kodza-scroll-down__icon" aria-hidden="true">
    <span class="kodza-scroll-down__wheel"></span>
  </span>
</button>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Scroll Down
   The cue at the bottom of a hero: an arrow in a ring, or a mouse (--mouse) whose wheel rolls.
   Now and then the glyph rolls down and a new one drops in from above; under the pointer, ink
   pours in from the top. A click glides to the section after the hero (or data-target), the
   first scroll fades it out, and it comes back at the top. data-hide="120" waits longer before
   it steps aside, data-hide="never" keeps it.
   Everything is tuned with the --kz-scroll-down-* variables. */
.kodza-scroll-down {
  --kz-scroll-down-ink: #0a0a0a;
  --kz-scroll-down-paper: #ffffff;
  --kz-scroll-down-line: rgba(10, 10, 10, 0.28);
  --kz-scroll-down-size: 52px;
  --kz-scroll-down-travel: 36px;
  --kz-scroll-down-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: relative;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--kz-scroll-down-ink);
  font: inherit;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.5s var(--kz-scroll-down-ease), transform 0.5s var(--kz-scroll-down-ease), visibility 0s;
}

.kodza-scroll-down:focus-visible {
  outline: 2px solid var(--kz-scroll-down-ink);
  outline-offset: 4px;
}

/* Past the hero it steps aside, slowly, and leaves the Tab order once it is gone */
.kodza-scroll-down.is-away {
  opacity: 0;
  transform: translateY(12px);
  visibility: hidden;
  transition: opacity 0.6s cubic-bezier(0.65, 0, 0.35, 1), transform 0.6s cubic-bezier(0.65, 0, 0.35, 1), visibility 0s linear 0.6s;
}

.kodza-scroll-down__icon {
  position: relative;
  display: block;
  width: var(--kz-scroll-down-size);
  height: var(--kz-scroll-down-size);
  border-radius: inherit;
  transition: transform 0.25s var(--kz-scroll-down-ease);
}

.kodza-scroll-down:active .kodza-scroll-down__icon {
  transform: scale(0.95);
}

.kodza-scroll-down__icon svg {
  display: block;
  width: 18px;
  height: 18px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The mouse: a body with its wheel near the top */
.kodza-scroll-down--mouse {
  --kz-scroll-down-travel: 14px;

  border-radius: 14px;
}

.kodza-scroll-down--mouse .kodza-scroll-down__icon {
  width: 28px;
  height: 44px;
}

.kodza-scroll-down__wheel {
  display: block;
  width: 2px;
  height: 7px;
  margin-top: 2px;
  border-radius: 1px;
  background: currentColor;
}

/* Built by the script: the outline, and an ink copy on top that pours in from the top */
.kodza-scroll-down__layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px var(--kz-scroll-down-line);
}

/* The mouse is a thinner shape than the ring: its outline takes more ink to read as clearly */
.kodza-scroll-down--mouse .kodza-scroll-down__layer:not(.kodza-scroll-down__layer--fill) {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--kz-scroll-down-ink) 50%, transparent);
}

.kodza-scroll-down__layer--fill {
  background: var(--kz-scroll-down-ink);
  color: var(--kz-scroll-down-paper);
  box-shadow: none;
  clip-path: inset(0 0 100% 0);
}

.kodza-scroll-down.is-in .kodza-scroll-down__layer--fill {
  clip-path: inset(0);
  transition: clip-path 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}

/* On the way out it drains through the bottom, the way the arrow points */
.kodza-scroll-down.is-out .kodza-scroll-down__layer--fill {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

/* The window the glyph rolls through: the whole ring, or a slit under the wheel */
.kodza-scroll-down__slot {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.kodza-scroll-down--mouse .kodza-scroll-down__slot {
  inset: 7px 11px auto;
  height: 16px;
}

.kodza-scroll-down__track {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.kodza-scroll-down--mouse .kodza-scroll-down__track {
  align-items: start;
}

.kodza-scroll-down__track > * {
  grid-area: 1 / 1;
}

/* The glyph waiting above, which drops into place as the first one leaves at the bottom */
.kodza-scroll-down__track > :last-child {
  transform: translateY(calc(-1 * var(--kz-scroll-down-travel)));
}

.kodza-scroll-down.is-rolling .kodza-scroll-down__track {
  animation: kodza-scroll-down-roll 0.85s cubic-bezier(0.65, 0, 0.35, 1);
}

@keyframes kodza-scroll-down-roll {
  to {
    transform: translateY(var(--kz-scroll-down-travel));
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-scroll-down,
  .kodza-scroll-down__icon,
  .kodza-scroll-down__layer--fill {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .kodza-scroll-down.is-rolling .kodza-scroll-down__track {
    animation: none;
  }
}

/* Theming example — on a dark background:
.dark-section .kodza-scroll-down {
  --kz-scroll-down-ink: #ffffff;
  --kz-scroll-down-paper: #0a0a0a;
  --kz-scroll-down-line: rgba(255, 255, 255, 0.34);
}
*/

/* kodza-guard e1c2797e16cd — 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-scroll-down):not(#_) {
  outline: revert;
  outline-offset: revert;
}

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

.kodza-scroll-down:not(#_) {
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  box-shadow: revert;
  appearance: 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-scroll-down__icon:not(#_),
.kodza-scroll-down__layer:not(#_),
.kodza-scroll-down__slot:not(#_),
.kodza-scroll-down__track:not(#_),
.kodza-scroll-down__wheel:not(#_) {
  box-sizing: revert;
}

.kodza-scroll-down__track 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;
}

/* 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-scroll-down:not(#_) {
  position: relative;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--kz-scroll-down-ink);
  font: inherit;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.5s var(--kz-scroll-down-ease), transform 0.5s var(--kz-scroll-down-ease), visibility 0s;
}

.kodza-scroll-down:focus-visible:not(#_) {
  outline: 2px solid var(--kz-scroll-down-ink);
  outline-offset: 4px;
}

.kodza-scroll-down.is-away:not(#_) {
  opacity: 0;
  transform: translateY(12px);
  visibility: hidden;
  transition: opacity 0.6s cubic-bezier(0.65, 0, 0.35, 1), transform 0.6s cubic-bezier(0.65, 0, 0.35, 1), visibility 0s linear 0.6s;
}

.kodza-scroll-down__icon svg:not(#_) {
  display: block;
}

.kodza-scroll-down--mouse:not(#_) {
  border-radius: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .kodza-scroll-down: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 — Scroll Down
// The cue at the bottom of a hero. Now and then its glyph rolls down and a new one drops in
// from above; under the pointer, ink pours in. A click glides to the section after the hero
// (or data-target) and, from the keyboard, moves the focus there. The first scroll past the
// hero fades it out, and it comes back at the top.
(() => {
  const SELECTOR = '.kodza-scroll-down';
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  const FIRST = 1400;
  const EVERY = 3600;

  // The box that scrolls it: the nearest scrolling ancestor, or the page (null)
  const scrollerOf = (el) => {
    for (let p = el.parentElement; p && p !== document.body && p !== document.documentElement; p = p.parentElement) {
      const { overflowY } = getComputedStyle(p);
      if ((overflowY === 'auto' || overflowY === 'scroll') && p.scrollHeight > p.clientHeight) return p;
    }
    return null;
  };

  // One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
  function mount(root, signal) {
    const icon = root.querySelector('.kodza-scroll-down__icon');
    const glyph = icon?.firstElementChild;
    if (!glyph) return;

    // The outline and its ink copy, each with the glyph and its twin waiting above
    const layer = (extra) => {
      const el = document.createElement('span');
      const slot = document.createElement('span');
      const track = document.createElement('span');
      el.className = `kodza-scroll-down__layer${extra}`;
      slot.className = 'kodza-scroll-down__slot';
      track.className = 'kodza-scroll-down__track';
      track.append(glyph.cloneNode(true), glyph.cloneNode(true));
      slot.append(track);
      el.append(slot);
      return el;
    };
    icon.replaceChildren(layer(''), layer(' kodza-scroll-down__layer--fill'));

    const scroller = scrollerOf(root);
    const scrollTop = () => (scroller ? scroller.scrollTop : window.scrollY);
    const viewHeight = () => (scroller ? scroller.clientHeight : innerHeight);
    const set = (y) => (scroller || window).scrollTo({ top: y, behavior: 'instant' });
    // Where an element sits in the scrolled box, whatever scale the box is drawn at
    const topOf = (el) => {
      const r = el.getBoundingClientRect();
      if (!scroller) return r.top + window.scrollY;
      const box = scroller.getBoundingClientRect();
      return (r.top - box.top) / (box.height / scroller.offsetHeight || 1) + scroller.scrollTop;
    };

    // The hero: the first block around it at least half a screen tall
    const heroOf = () => {
      for (let el = root.parentElement; el && el !== scroller && el !== document.body; el = el.parentElement) {
        if (el.offsetHeight >= viewHeight() * 0.5) return el;
      }
      return null;
    };

    // The next section: data-target (or the link's #hash), else what follows the hero
    const targetOf = () => {
      const href = root.getAttribute('href');
      const wanted = root.dataset.target || (href && href.length > 1 && href.startsWith('#') ? href : '');
      if (wanted) {
        try {
          const found = document.querySelector(wanted);
          if (found) return found;
        } catch { /* not a selector: fall back to the next section */ }
      }
      for (let el = heroOf() || root.parentElement; el && el !== document.body; el = el.parentElement) {
        for (let next = el.nextElementSibling; next; next = next.nextElementSibling) {
          if (next.offsetHeight > 0) return next;
        }
      }
      return null;
    };

    // The roll: both copies of the glyph move together, the twin lands where the glyph was
    let rolling = false;
    const roll = () => {
      if (reduceMotion || rolling) return;
      rolling = true;
      root.classList.add('is-rolling');
    };
    root.addEventListener('animationend', (event) => {
      if (event.animationName !== 'kodza-scroll-down-roll') return;
      rolling = false;
      root.classList.remove('is-rolling');
    }, { signal });

    // Now and then, only while it is shown and on screen
    let away = false;
    let inView = false;
    let timer = 0;
    const schedule = (wait = EVERY) => {
      clearTimeout(timer);
      if (reduceMotion || away || !inView) return;
      timer = setTimeout(() => {
        if (!document.hidden) roll();
        schedule();
      }, wait);
    };
    const seen = new IntersectionObserver(([entry]) => {
      inView = entry.isIntersecting;
      schedule(FIRST);
    });
    seen.observe(root);

    // The ink: pours in under the pointer (or the keyboard focus), drains through the bottom
    let hovered = false;
    const sync = () => {
      const want = !away && (hovered || root.matches(':focus-visible'));
      const filled = root.classList.contains('is-in');
      if (want && !filled) {
        root.classList.remove('is-out');
        root.classList.add('is-in');
        roll();
        schedule();
      } else if (!want && filled) {
        root.classList.remove('is-in');
        root.classList.add('is-out');
      }
    };
    const fill = icon.querySelector('.kodza-scroll-down__layer--fill');
    fill.addEventListener('transitionend', (event) => {
      if (event.propertyName === 'clip-path' && root.classList.contains('is-out')) root.classList.remove('is-out');
    }, { signal });
    root.addEventListener('pointerenter', (event) => {
      if (event.pointerType === 'touch') return;
      hovered = true;
      sync();
    }, { signal });
    root.addEventListener('pointerleave', () => {
      hovered = false;
      sync();
    }, { signal });
    root.addEventListener('focus', sync, { signal });
    root.addEventListener('blur', sync, { signal });

    // Shown at rest, faded once the page has scrolled past the top of its hero
    const limit = root.dataset.hide === 'never' ? Infinity : parseFloat(root.dataset.hide) || 40;
    const update = () => {
      const hero = heroOf();
      let rest = hero ? topOf(hero) : 0;
      if (rest < viewHeight() / 2) rest = 0;
      const now = scrollTop() > rest + limit;
      if (now === away) return;
      away = now;
      root.classList.toggle('is-away', away);
      if (away) hovered = false;
      sync();
      schedule(FIRST);
    };

    // The glide: eased, and dropped as soon as the visitor scrolls or presses anything
    let glide = null;
    const stop = () => {
      glide?.abort();
      glide = null;
    };
    const glideTo = (y) => {
      stop();
      const box = scroller || document.documentElement;
      const from = scrollTop();
      const to = Math.max(0, Math.min(box.scrollHeight - (scroller ? scroller.clientHeight : innerHeight), y));
      if (reduceMotion || Math.abs(to - from) < 2) {
        set(to);
        return;
      }
      const controller = new AbortController();
      glide = controller;
      const duration = Math.min(1400, 500 + Math.abs(to - from) * 0.45);
      const start = performance.now();
      const step = (now) => {
        if (controller.signal.aborted) return;
        const t = Math.min(1, (now - start) / duration);
        set(from + (to - from) * (t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2));
        if (t < 1) requestAnimationFrame(step);
        else stop();
      };
      requestAnimationFrame(step);
      ['wheel', 'touchstart', 'pointerdown', 'keydown'].forEach((type) => {
        window.addEventListener(type, stop, { passive: true, signal: controller.signal });
      });
    };

    // From the keyboard the focus follows, on the section itself if nothing in it takes it
    const focusOn = (el) => {
      if (!el.matches('a[href], button, input, select, textarea, [tabindex]')) {
        const outline = el.style.outline;
        el.setAttribute('tabindex', '-1');
        el.style.outline = 'none';
        el.addEventListener('blur', () => {
          el.removeAttribute('tabindex');
          el.style.outline = outline;
        }, { once: true, signal });
      }
      el.focus({ preventScroll: true });
    };

    root.addEventListener('click', (event) => {
      const target = targetOf();
      if (root.matches('a')) event.preventDefault();
      if (!target) {
        glideTo(scrollTop() + viewHeight());
        return;
      }
      glideTo(topOf(target) - (parseFloat(getComputedStyle(target).scrollMarginTop) || 0));
      if (event.detail === 0) focusOn(target);
    }, { signal });

    let ticking = false;
    (scroller || window).addEventListener('scroll', () => {
      if (ticking) return;
      ticking = true;
      requestAnimationFrame(() => {
        ticking = false;
        if (!signal.aborted) update();
      });
    }, { passive: true, signal });
    window.addEventListener('resize', update, { signal });
    signal.addEventListener('abort', () => {
      stop();
      clearTimeout(timer);
      seen.disconnect();
    });
    update();
  }

  // Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
  // event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
  // markup back. For themes and apps that swap content without a page load. Each running root
  // keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
  // component inside another one is saved as written, not half-started, and stopped with it.
  const KODZA = Symbol.for('kodza');
  const instances = new WeakMap();
  const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
  const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
  const put = (el, saved) => {
    [...el.attributes].forEach((a) => el.removeAttribute(a.name));
    saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
    el.innerHTML = saved.html;
  };
  // The markup inside a root as written: Kodza components already running in it give back their own
  const written = (root) => {
    const all = [...root.querySelectorAll('*')];
    if (!all.some((el) => el[KODZA])) return root.innerHTML;
    const copy = root.cloneNode(true);
    const twins = copy.querySelectorAll('*');
    let last = null;
    all.forEach((el, i) => {
      if (!el[KODZA] || last?.contains(el)) return;
      last = el;
      put(twins[i], el[KODZA]);
    });
    return copy.innerHTML;
  };
  const init = (scope) => find(scope).forEach((root) => {
    if (root.classList.contains('is-ready')) return; // already running, maybe from another copy of this script
    const controller = new AbortController();
    const saved = { html: written(root), attrs: attrsOf(root), stop: () => destroy(root) };
    instances.set(root, { controller, saved });
    root[KODZA] = saved;
    mount(root, controller.signal);
    root.classList.add('is-ready');
  });
  const destroy = (scope) => find(scope).forEach((root) => {
    const instance = instances.get(root);
    if (!instance) return;
    instances.delete(root);
    // The Kodza components running inside it stop first: once its markup is put back, their own
    // script could not find them any more
    root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
    instance.controller.abort();
    delete root[KODZA];
    put(root, instance.saved);
  });
  document.addEventListener('kodza:init', (event) => init(event.detail?.root));
  document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
  init();
  // Loaded in <head>, the script runs before the markup exists: once more when it is parsed
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
```

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