# Call Button

> A round phone icon that opens into a full "Book a call" button, with a little ring. Stays open on touch screens. Pure CSS.

Buttons · hover, button, expand, icon · HTML and CSS only · no dependencies · updated 2026-10-16
Demo: https://kodza.dev/components/call-button-expand/

## Files

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

- [`kodza-call-button-expand.css`](https://kodza.dev/registry/call-button-expand/kodza-call-button-expand.css) · 6.2 KB
- [`kodza-call-button-expand.html`](https://kodza.dev/registry/call-button-expand/kodza-call-button-expand.html) · 0.4 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-call-button-expand.css https://kodza.dev/registry/call-button-expand/kodza-call-button-expand.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-call-button`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-call-bg: #0a0a0a`
  - `--kz-call-fg: #ffffff`
  - `--kz-call-size: 52px`
  - `--kz-call-duration: 0.6s`
  - `--kz-call-ease: cubic-bezier(0.22, 1, 0.36, 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-call-button {
    --kz-call-bg: #ffffff;
    --kz-call-fg: #0a0a0a;
  }
}
```

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

## Use it

### Plain HTML page

- CSS: `kodza/kodza-call-button-expand.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-call-button-expand.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-call-button-expand.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-call-button-expand', $uri . 'kodza-call-button-expand.css', [], filemtime($dir . 'kodza-call-button-expand.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-call-button { --kz-call-bg: var(ACCENT, #0a0a0a); --kz-call-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-call-button-expand.css` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-call-button-expand.css' | asset_url | stylesheet_tag }}`, then the HTML.

### React / Next.js

- Files, side by side (e.g. in `components/kodza/`): `CallButton.tsx` (below), the CSS block under Code saved as `call-button-expand.css`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { CallButton } from '@/components/kodza/CallButton';` then `<CallButton>Book a call</CallButton>`. Props: `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-call-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 './call-button-expand.css'` line there.

```tsx
'use client';
// Kodza — Call Button, for React. From https://kodza.dev/components/call-button-expand/
// 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: call-button-expand.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 './call-button-expand.css';

export type CallButtonProps = Omit<ComponentPropsWithoutRef<'a'>, "children" | "vars"> & {
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #0a0a0a */
    "--kz-call-bg"?: string | number;
    /** default: #ffffff */
    "--kz-call-fg"?: string | number;
    /** default: 52px */
    "--kz-call-size"?: string | number;
    /** default: 0.6s */
    "--kz-call-duration"?: string | number;
    /** default: cubic-bezier(0.22, 1, 0.36, 1) */
    "--kz-call-ease"?: string | number;
  };
  /** The text */
  children?: string;
  className?: string;
};

export function CallButton({ vars, children = "Book a call", className, style, ...rest }: CallButtonProps) {
  const ref = useRef<ComponentRef<'a'>>(null);
  const classes = ["kodza-call-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="tel:+33100000000" key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <span className="kodza-call-button__icon" aria-hidden="true">
        <svg viewBox="0 0 24 24">
          <path d="M6.6 3.5h2.6l1.4 4-1.9 1.3a11 11 0 0 0 6.5 6.5l1.3-1.9 4 1.4v2.6a2 2 0 0 1-2.2 2A16.5 16.5 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2z" />
        </svg>
      </span>
      {' '}
      <span className="kodza-call-button__label">
        <span>{children}</span>
      </span>
    </a>
  );
}
```

## Code

```html
<a class="kodza-call-button" href="tel:+33100000000">
  <span class="kodza-call-button__icon" aria-hidden="true">
    <svg viewBox="0 0 24 24"><path d="M6.6 3.5h2.6l1.4 4-1.9 1.3a11 11 0 0 0 6.5 6.5l1.3-1.9 4 1.4v2.6a2 2 0 0 1-2.2 2A16.5 16.5 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2z" /></svg>
  </span>
  <span class="kodza-call-button__label"><span>Book a call</span></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 — Call Button
   A round icon that opens into a full button: the label slides out from behind the icon,
   and the phone gives a little ring. On touch screens, where nothing hovers, it stays open.
   Pure CSS, tuned with the --kz-call-* variables. */
.kodza-call-button {
  --kz-call-bg: #0a0a0a;
  --kz-call-fg: #ffffff;
  --kz-call-size: 52px;
  --kz-call-duration: 0.6s;
  --kz-call-ease: cubic-bezier(0.22, 1, 0.36, 1);

  display: inline-grid;
  grid-template-columns: var(--kz-call-size) 0fr;
  align-items: center;
  height: var(--kz-call-size);
  border-radius: 999px;
  background: var(--kz-call-bg);
  color: var(--kz-call-fg);
  font: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: grid-template-columns var(--kz-call-duration) var(--kz-call-ease), transform 0.25s var(--kz-call-ease);
}

.kodza-call-button__icon {
  display: grid;
  place-items: center;
}

.kodza-call-button__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  transform-origin: 50% 60%;
}

/* The label column opens from 0 to its natural width */
.kodza-call-button__label {
  min-width: 0;
  overflow: hidden;
}

.kodza-call-button__label > span {
  display: block;
  padding-right: 24px;
  opacity: 0;
  transform: translateX(-12px);
  transition:
    opacity calc(var(--kz-call-duration) * 0.5) ease,
    transform var(--kz-call-duration) var(--kz-call-ease);
}

.kodza-call-button:hover,
.kodza-call-button:focus-visible {
  grid-template-columns: var(--kz-call-size) 1fr;
}

.kodza-call-button:hover .kodza-call-button__label > span,
.kodza-call-button:focus-visible .kodza-call-button__label > span {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--kz-call-duration) * 0.15);
}

.kodza-call-button:hover .kodza-call-button__icon svg,
.kodza-call-button:focus-visible .kodza-call-button__icon svg {
  animation: kodza-call-ring 0.9s ease-in-out;
}

.kodza-call-button:active {
  transform: scale(0.97);
}

.kodza-call-button:focus-visible {
  outline: 2px solid var(--kz-call-bg);
  outline-offset: 3px;
}

@keyframes kodza-call-ring {
  0%, 100% { transform: rotate(0); }
  12% { transform: rotate(-16deg); }
  24% { transform: rotate(14deg); }
  36% { transform: rotate(-11deg); }
  48% { transform: rotate(8deg); }
  60% { transform: rotate(-4deg); }
  72% { transform: rotate(0); }
}

/* Touch screens: nothing hovers, so the button shows its label from the start */
@media (hover: none) {
  .kodza-call-button {
    grid-template-columns: var(--kz-call-size) 1fr;
  }

  .kodza-call-button__label > span {
    opacity: 1;
    transform: none;
  }
}

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

  .kodza-call-button__icon svg {
    animation: none !important;
  }
}

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

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

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

.kodza-call-button:not(#_) {
  border: revert;
  padding: revert;
  list-style: revert;
  box-sizing: revert;
  position: revert;
  box-shadow: 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;
}

.kodza-call-button__icon:not(#_),
.kodza-call-button__label:not(#_),
.kodza-call-button__label span:where(:not([class*="kodza-"])):not(#_) {
  box-sizing: revert;
}

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

.kodza-call-button__icon svg:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-call-button__icon svg:where(:not([class*="kodza-"])):not(#_):where([hidden]) {
  display: none;
}

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

.kodza-call-button:not(#_) {
  display: inline-grid;
  border-radius: 999px;
  background: var(--kz-call-bg);
  color: var(--kz-call-fg);
  font: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: grid-template-columns var(--kz-call-duration) var(--kz-call-ease), transform 0.25s var(--kz-call-ease);
}

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

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

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