# Styling

Restyle Bunny's React components to match your brand with the appearance prop, using variables, rules and fonts, on BunnyProvider or on a single component.

Every Bunny component is styled through one prop, `appearance`. Set it on `BunnyProvider` to restyle every component inside it, or on any component to restyle just that one on top of the provider’s. `style` and `className` on a component are for positioning only.

`appearance` has three parts:

- `variables`: colors, font, radius and spacing the default look is built from. Change one and everything built from it follows.
- `rules`: per-selector overrides such as `.Input`, `.Label` or `.Button`, merged over the defaults.
- `fonts`: web fonts for `variables.fontFamily`, loaded onto the page and into the payment fields.

```tsx
import { BunnyProvider, Checkout } from "@bunnyapp/components";

<BunnyProvider
  apiHost={apiHost}
  token={token}
  appearance={{
    variables: {
      colorPrimary: "#14532d",
      colorBackgroundSecondary: "#f6f1e7",
      fontFamily: "Inter, sans-serif",
    },
    rules: {
      ".Input:focus": { borderColor: "#14532d" },
    },
    fonts: [
      { cssSrc: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" },
    ],
  }}
>
  <Checkout priceListCode="business-monthly" />
</BunnyProvider>
```

## Examples

Two looks built only with `appearance`, shown on Checkout. The same object restyles every other component, including the card fields.

**Ledger**

Editorial and print-like: warm paper, ink hairlines, square corners and a serif face.

 [image: Checkout in the Ledger style: cream background, serif type, square black-bordered inputs, a black selected Card tab and a black Pay button with spaced lettering]

Checkout with the Ledger appearance.

```tsx
const ledger = {
  variables: {
    colorPrimary: "#14532d",
    colorBackground: "#fffdf8",
    colorBackgroundSecondary: "#f6f1e7",
    colorText: "#1c1917",
    colorTextSecondary: "#6b635a",
    colorTextPlaceholder: "#a8a096",
    colorDanger: "#9f1239",
    colorSuccess: "#14532d",
    colorBorder: "#1c1917",
    borderWidth: "1px",
    borderRadius: "0px",
    fontFamily: '"Source Serif 4", Georgia, serif',
    fontSizeBase: "16px",
    focusBoxShadow: "none",
    gridRowSpacing: "24px",
  },
  rules: {
    ".Label": { fontSize: "14px", fontWeight: "600", color: "#6b635a", marginBottom: "8px" },
    ".Input": { padding: "11px 12px" },
    ".Input:hover": { borderColor: "#1c1917" },
    ".Input:focus": { borderColor: "#14532d", boxShadow: "0 0 0 1px #14532d" },
    ".Input--invalid": { borderColor: "#9f1239", boxShadow: "0 0 0 1px #9f1239" },
    ".Error": { fontSize: "13px" },
    ".Tab": { fontWeight: "500" },
    ".Tab:hover": { borderColor: "#1c1917" },
    ".Tab--selected": { backgroundColor: "#1c1917", color: "#fffdf8", borderColor: "#1c1917" },
    ".Tab:focus": { boxShadow: "0 0 0 1px #14532d" },
    ".Button": {
      backgroundColor: "#1c1917",
      color: "#fffdf8",
      letterSpacing: "0.1em",
      fontSize: "13px",
      fontWeight: "600",
      padding: "14px 16px",
    },
    ".Button:hover": { backgroundColor: "#14532d" },
    ".Button:active": { backgroundColor: "#052e16" },
    ".Tag": { fontWeight: "600", textTransform: "uppercase", letterSpacing: "0.06em", fontSize: "11px" },
    ".Card": { border: "1px solid #1c1917", boxShadow: "none" },
    ".Switch--checked": { backgroundColor: "#14532d" },
    ".Heading": { letterSpacing: "-0.01em" },
    ".Amount": { fontWeight: "600" },
    ".Overline": { color: "#1c1917", letterSpacing: "0.08em" },
    ".Document": { border: "1px solid #1c1917", boxShadow: "none" },
  },
  fonts: [
    { cssSrc: "https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@400;500;600&display=swap" },
  ],
};
```

**Midnight**

Dark fintech: navy columns, filled inputs, a lime accent, a pill button and a monospace face.

 [image: Checkout in the Midnight style: dark navy background, monospace type, filled navy inputs, a lime-outlined selected Card tab, a lime total and a rounded lime Pay button]

Checkout with the Midnight appearance.

```tsx
const midnight = {
  variables: {
    colorPrimary: "#a3e635",
    colorOnPrimary: "#0b1020", // lime is light, so text on it is dark navy
    colorBackground: "#0f1629",
    colorBackgroundSecondary: "#0b1020",
    colorText: "#e6e9f2",
    colorTextSecondary: "#8b93a7",
    colorTextPlaceholder: "#5b6478",
    colorDanger: "#fb7185",
    colorSuccess: "#a3e635",
    colorBorder: "#1c2540",
    borderWidth: "1px",
    borderRadius: "12px",
    fontFamily: '"IBM Plex Mono", ui-monospace, monospace',
    fontSizeBase: "15px",
    focusBoxShadow: "0 0 0 4px rgba(163, 230, 53, 0.2)",
    gridRowSpacing: "22px",
  },
  rules: {
    ".Label": { color: "#8b93a7", fontSize: "13px", fontWeight: "500" },
    ".Input": { backgroundColor: "#151d36", borderColor: "#151d36", padding: "15px 16px" },
    ".Input:hover": { borderColor: "#2a3558" },
    ".Input:focus": { borderColor: "#a3e635" },
    ".Tab": { backgroundColor: "#151d36", borderColor: "#151d36" },
    ".Tab:hover": { borderColor: "#2a3558" },
    ".Tab--selected": { backgroundColor: "#18223f", borderColor: "#a3e635", color: "#a3e635" },
    ".Button": { borderRadius: "999px", fontWeight: "600", padding: "15px 20px" },
    ".Button:hover": { backgroundColor: "#bef264" },
    ".Button:active": { backgroundColor: "#84cc16" },
    ".Tag": { backgroundColor: "#18223f", color: "#a3e635", fontWeight: "600" },
    ".Card": { backgroundColor: "#151d36", boxShadow: "0 8px 24px rgba(0, 0, 0, 0.4)" },
    ".Switch--checked": { backgroundColor: "#a3e635" },
    ".TextSecondary": { color: "#8b93a7" },
    ".Amount--display": { color: "#a3e635" },
    ".Overline": { color: "#a3e635", letterSpacing: "0.08em" },
  },
  fonts: [
    { cssSrc: "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap" },
  ],
};
```

## Learning the API

The `Appearance` type is the reference. Type `appearance={{` in your editor and use autocomplete and hover: every variable documents its default, and most selectors do too.

For the full styling guide (fonts, payment fields, CSP) and upgrading from 1.x, see the Styling components and Migrating to 2.0 sections of the README in the installed package, `node_modules/@bunnyapp/components/README.md`. The README shown on npmjs.com is the 1.x one until 2.0.0 is released.

The `bunny-components` [agent skill](https://docs.bunny.com/developer/bunny-components/bunny-components#using-with-an-ai-assistant) can write an `appearance` object for you.

---

Source: https://docs.bunny.com/developer/bunny-components/styling. Index of every page: https://docs.bunny.com/llms.txt
