# Morph Button

> A pill that tightens into a circle on hover while its label gives way to an arrow. The clickable area never moves. Pure CSS.

Buttons · hover, button, morph, clip-path · HTML and CSS only · no dependencies · updated 2026-10-16
Demo: https://kodza.dev/components/button-svg-morph/

## Files

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

- [`kodza-button-svg-morph.css`](https://kodza.dev/registry/button-svg-morph/kodza-button-svg-morph.css) · 8.6 KB
- [`kodza-button-svg-morph.html`](https://kodza.dev/registry/button-svg-morph/kodza-button-svg-morph.html) · 0.3 KB · the markup, to adapt and paste into your page

**Can you run shell commands? Download the CSS, don't retype it.** 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-button-svg-morph.css https://kodza.dev/registry/button-svg-morph/kodza-button-svg-morph.css
```

Then load the file 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 from the Code section only if you can't run commands, exactly as it is. (Windows PowerShell: `curl.exe`.)

## API

- Root: `.kodza-morph-button`
- Element: an `<a href>` for a link, or a `<button type="button">` (`type="submit"` in a form) for an action. Same classes, same look.
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-morph-bg: #0a0a0a`
  - `--kz-morph-fg: #ffffff`
  - `--kz-morph-height: 52px`
  - `--kz-morph-pad-x: 34px`
  - `--kz-morph-duration: 0.6s`
  - `--kz-morph-ease: cubic-bezier(0.76, 0, 0.24, 1)`
  - `--kz-morph-spring: cubic-bezier(0.34, 1.56, 0.64, 1)`

## 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-morph-button {
    --kz-morph-bg: #ffffff;
    --kz-morph-fg: #0a0a0a;
  }
}
```

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

## Use it

### Plain HTML page

- CSS: `kodza/kodza-button-svg-morph.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-button-svg-morph.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.
- No JS.
- 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">`.

### Claude artifact (claude.ai)

- Paste the CSS in a `<style>`, 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>`, then `sed -e '/^KODZA-CSS$/{r kodza/kodza-button-svg-morph.css' -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: the downloaded file goes 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-button-svg-morph', $uri . 'kodza-button-svg-morph.css', [], filemtime($dir . 'kodza-button-svg-morph.css'));
  });
  ```
  Scoped to `kodza-` classes, the CSS never touches the theme.
- 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).
- No JS.
- Colours: by default, match the theme's palette. After the component's CSS, point these variables at the theme's colours, on the component root, Kodza's value as the fallback:
  `.kodza-morph-button { --kz-morph-bg: var(ACCENT, #0a0a0a); --kz-morph-fg: var(BACKGROUND, #ffffff); }`
  TEXT, BACKGROUND and ACCENT (the colour the theme fills its own buttons with) are the theme's own colour variables — block themes (theme.json, like Twenty Twenty-Five): `--wp--preset--color--contrast`, `--wp--preset--color--base`, `--wp--preset--color--contrast` (they fill their buttons with it; their accent-1… colours are decorative); Astra: `--ast-global-color-2`, `--ast-global-color-4`, `--ast-global-color-0`; Kadence: `--global-palette3`, `--global-palette9`, `--global-palette1`; GeneratePress: `--contrast`, `--base-3`, `--accent`; Blocksy: `--theme-palette-color-4`, `--theme-palette-color-8`, `--theme-palette-color-1`. Use only these names, and only if the site really has them (the theme's CSS, or Styles → Colors): the `--wp--preset--color--black`, `--white`, `--vivid-…` that WordPress adds everywhere are not the theme's palette. Another theme, or one without these variables (Hello Elementor, OceanWP): leave the variables alone, it keeps Kodza's monochrome; same when the developer asks for monochrome or the Kodza look. Leave the translucent greys (`rgba(10, 10, 10, …)`) as they are: they suit any light background. On a dark palette, set the other variables from Dark mode too.
- WordPress turns straight quotes and `--` into typographic ones in the text of a Custom HTML block (not inside `<code>` or `<pre>`).

#### With Elementor

- HTML: an **HTML** widget (Elementor shows it to administrators only). It keeps the code exactly as pasted, straight quotes included.
- CSS: 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.
- No child theme: the CSS can go in the HTML widget instead, in a `<style>` before the HTML.

### Shopify

- Files: `assets/kodza-button-svg-morph.css` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-button-svg-morph.css' | asset_url | stylesheet_tag }}`, then the HTML.

### React / Next.js

- Files, side by side (e.g. in `components/kodza/`): `MorphButton.tsx` (below), the CSS block under Code saved as `button-svg-morph.css`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { MorphButton } from '@/components/kodza/MorphButton';` then `<MorphButton>Take me there</MorphButton>`. Props: `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-morph-bg': … }}`), `children` (the text, plain), `className`, `style` and the other props of its `<a>` (`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 './button-svg-morph.css'` line there.

```tsx
'use client';
// Kodza — Morph Button, for React. From https://kodza.dev/components/button-svg-morph/
// 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: button-svg-morph.css, the component's CSS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
import { useRef, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './button-svg-morph.css';

export type MorphButtonProps = Omit<ComponentPropsWithoutRef<'a'>, "children" | "vars"> & {
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #0a0a0a */
    "--kz-morph-bg"?: string | number;
    /** default: #ffffff */
    "--kz-morph-fg"?: string | number;
    /** default: 52px */
    "--kz-morph-height"?: string | number;
    /** default: 34px */
    "--kz-morph-pad-x"?: string | number;
    /** default: 0.6s */
    "--kz-morph-duration"?: string | number;
    /** default: cubic-bezier(0.76, 0, 0.24, 1) */
    "--kz-morph-ease"?: string | number;
    /** default: cubic-bezier(0.34, 1.56, 0.64, 1) */
    "--kz-morph-spring"?: string | number;
  };
  /** The text */
  children?: string;
  className?: string;
};

export function MorphButton({ vars, children = "Take me there", className, style, ...rest }: MorphButtonProps) {
  const ref = useRef<ComponentRef<'a'>>(null);
  const classes = ["kodza-morph-button", 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, children, style, rest]);

  return (
    <a href="#" key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <span className="kodza-morph-button__label">{children}</span>
      {' '}
      <span className="kodza-morph-button__mark" aria-hidden="true">
        <svg className="kodza-morph-button__icon" viewBox="0 0 24 24">
          <path d="M5 12h14M13 6l6 6-6 6" />
        </svg>
      </span>
    </a>
  );
}
```

## Code

```html
<a class="kodza-morph-button" href="#">
  <span class="kodza-morph-button__label">Take me there</span>
  <span class="kodza-morph-button__mark" aria-hidden="true"><svg class="kodza-morph-button__icon" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6" /></svg></span>
</a>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Morph Button
   On hover the pill closes in on itself until only a circle is left: the words are cut by the
   closing edges as they move on, and an arrow slides into the circle from behind them. Only
   the painted shape changes: the clickable area keeps its size, so the button never slips
   away from under the pointer. Pure CSS, tuned with the --kz-morph-* variables. */
.kodza-morph-button {
  --kz-morph-bg: #0a0a0a;
  --kz-morph-fg: #ffffff;
  --kz-morph-height: 52px;
  --kz-morph-pad-x: 34px;
  --kz-morph-duration: 0.6s;
  --kz-morph-ease: cubic-bezier(0.76, 0, 0.24, 1);
  --kz-morph-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  position: relative;
  display: inline-grid;
  place-items: center;
  height: var(--kz-morph-height);
  padding: 0 var(--kz-morph-pad-x);
  border: 0;
  background: none;
  color: var(--kz-morph-fg);
  font: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

/* The shape: a pill that closes in on itself until only a circle is left */
.kodza-morph-button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background: var(--kz-morph-bg);
  clip-path: inset(0 0 round 999px);
  transition: clip-path var(--kz-morph-duration) var(--kz-morph-ease), transform 0.25s var(--kz-morph-ease);
}

.kodza-morph-button__label,
.kodza-morph-button__mark {
  grid-area: 1 / 1;
}

/* The words: cut by the same closing edges as the shape, moving on as they go */
.kodza-morph-button__label {
  clip-path: inset(-4px 0);
  transition:
    clip-path var(--kz-morph-duration) var(--kz-morph-ease),
    transform var(--kz-morph-duration) var(--kz-morph-ease),
    opacity calc(var(--kz-morph-duration) * 0.5) ease calc(var(--kz-morph-duration) * 0.2);
}

/* The arrow lives in a window the size of the final circle, and slides in from behind */
.kodza-morph-button__mark {
  display: grid;
  place-items: center;
  width: var(--kz-morph-height);
  height: var(--kz-morph-height);
  overflow: hidden;
  border-radius: 50%;
  pointer-events: none;
}

.kodza-morph-button__icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: translateX(-34px);
  transition:
    transform calc(var(--kz-morph-duration) * 0.8) var(--kz-morph-ease),
    opacity calc(var(--kz-morph-duration) * 0.3) ease;
}

.kodza-morph-button:hover::before,
.kodza-morph-button:focus-visible::before {
  clip-path: inset(0 calc(50% - var(--kz-morph-height) / 2) round 999px);
}

.kodza-morph-button:hover .kodza-morph-button__label,
.kodza-morph-button:focus-visible .kodza-morph-button__label {
  clip-path: inset(-4px calc(50% - var(--kz-morph-height) * 0.44));
  opacity: 0;
  transform: translateX(26px);
  transition:
    clip-path var(--kz-morph-duration) var(--kz-morph-ease),
    transform var(--kz-morph-duration) var(--kz-morph-ease),
    opacity calc(var(--kz-morph-duration) * 0.45) ease calc(var(--kz-morph-duration) * 0.3);
}

.kodza-morph-button:hover .kodza-morph-button__icon,
.kodza-morph-button:focus-visible .kodza-morph-button__icon {
  opacity: 1;
  transform: none;
  transition:
    transform calc(var(--kz-morph-duration) * 0.85) var(--kz-morph-ease) calc(var(--kz-morph-duration) * 0.25),
    opacity calc(var(--kz-morph-duration) * 0.3) ease calc(var(--kz-morph-duration) * 0.3);
}

.kodza-morph-button:active::before {
  transform: scale(0.94);
}

.kodza-morph-button:focus-visible {
  outline: none;
}

.kodza-morph-button:focus-visible::after {
  content: "";
  position: absolute;
  inset: -5px calc(50% - var(--kz-morph-height) / 2 - 5px);
  border: 2px solid var(--kz-morph-bg);
  border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  .kodza-morph-button::before,
  .kodza-morph-button__label,
  .kodza-morph-button__icon {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* Theming example — on a dark background:
.dark-section .kodza-morph-button {
  --kz-morph-bg: #ffffff;
  --kz-morph-fg: #0a0a0a;
}
*/

/* kodza-guard f3edeae8b93f — 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-morph-button):not(#_) {
  outline: revert;
}

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

.kodza-morph-button:not(#_) {
  border-radius: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-height: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  min-height: revert;
}

.kodza-morph-button__label:not(#_),
.kodza-morph-button__mark:not(#_) {
  box-sizing: revert;
}

.kodza-morph-button__icon:not(#_) {
  border: revert;
  margin: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-morph-button__icon:not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-morph-button__icon:not(#_):where([hidden]) {
  display: none;
}

.kodza-morph-button:not(#_)::before,
.kodza-morph-button: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-morph-button:not(#_) {
  position: relative;
  display: inline-grid;
  place-items: center;
  height: var(--kz-morph-height);
  padding: 0 var(--kz-morph-pad-x);
  border: 0;
  background: none;
  color: var(--kz-morph-fg);
  font: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.kodza-morph-button:not(#_)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background: var(--kz-morph-bg);
  clip-path: inset(0 0 round 999px);
  transition: clip-path var(--kz-morph-duration) var(--kz-morph-ease), transform 0.25s var(--kz-morph-ease);
}

.kodza-morph-button__icon:not(#_) {
  transition: transform calc(var(--kz-morph-duration) * 0.8) var(--kz-morph-ease),
    opacity calc(var(--kz-morph-duration) * 0.3) ease;
}

.kodza-morph-button:hover:not(#_)::before,
.kodza-morph-button:focus-visible:not(#_)::before {
  clip-path: inset(0 calc(50% - var(--kz-morph-height) / 2) round 999px);
}

.kodza-morph-button:hover .kodza-morph-button__icon:not(#_),
.kodza-morph-button:focus-visible .kodza-morph-button__icon:not(#_) {
  transition: transform calc(var(--kz-morph-duration) * 0.85) var(--kz-morph-ease) calc(var(--kz-morph-duration) * 0.25),
    opacity calc(var(--kz-morph-duration) * 0.3) ease calc(var(--kz-morph-duration) * 0.3);
}

.kodza-morph-button:active:not(#_)::before {
  transform: scale(0.94);
}

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

.kodza-morph-button:focus-visible:not(#_)::after {
  content: "";
  position: absolute;
  inset: -5px calc(50% - var(--kz-morph-height) / 2 - 5px);
  border: 2px solid var(--kz-morph-bg);
  border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  .kodza-morph-button:not(#_)::before {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-morph-button__icon:not(#_) {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
```

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