v2.0.2

Theme

The Style guide shows every text style, color, shape and step of space Canopy draws with, in your site's theme.

Colors

Canopy exposes a single theme block in canopy.yml to control the site-wide accent palette, gray palette, and base appearance. These values generated CSS variables ship with your project so your user interface and MDX components stay in sync and accessible. Modify the canopy.yml file in the root of your project to adjust these settings. Updating this configuration will require a rebuild of your project to take effect. Here is an example configuration:

canopy.yml
theme:  appearance: dark  accentColor: bronze  grayColor: sand
  • appearance sets the design token ramp: light (the default), dark, or auto.
  • accentColor drives buttons, links, checkboxes, and focus rings. Name one of the palettes below, or give any color as hex.
  • grayColor sets the base neutral ramp used for page backgrounds, card borders, and typography.

Any accent color

accentColor also takes a hex color, quoted so YAML reads it as text. Canopy derives the other steps from it, from the page's tint to the darkest text.

canopy.yml
theme:  accentColor: "#0f62fe"  grayColor: slate

Light, dark, or the visitor's choice

With appearance: auto, each page follows the visitor's system setting, light or dark, from the moment it loads. CanopyFooter adds an Appearance select (System, Light or Dark), and the browser remembers the choice for your site. Its labels come from common.appearance in locale.yml. A site with a footer of its own can place <AppearanceToggle /> wherever it likes, once on a page.

canopy.yml
theme:  appearance: auto

Without JavaScript, the page still follows the system setting, and the select is not shown.

Contrast

Every palette and any hex color keeps Canopy's text at a contrast ratio of at least 4.5:1, in light and dark, so links, muted text and button labels stay readable (WCAG 2.2, 1.4.3). A step that would fall short is darkened (or, in dark mode, lightened) only as far as that needs. Most palettes keep Radix's own steps. If you set --color-accent-* or --color-gray-* yourself, keeping those ratios is up to you.

Click any accent or gray swatch below to temporarily override those palettes, or flip between light/dark using the appearance buttons. The overrides inject a small helper script (scoped to this docs page) that forces the relevant CSS variables with !important so you can preview combinations without editing canopy.yml. Reset overrides jumps back to the default light/gold/sand preview.

Appearance

Pick the base light or dark mode for the theme preview.

Color scales

Accent and gray ramps from the active theme.

Accent
50
100
200
300
400
500
600
700
800
900
Gray
50
100
200
300
400
500
600
700
800
900

Accent color palette options

Click a swatch to temporarily override the accent palette.

Gray color palette options

Click a swatch to preview the neutral ramp for surfaces and text.

Typography

Canopy sets its type as a magazine does. Headlines and the interface (navigation, buttons, cards, labels, metadata, search) are in Google Sans Flex. Reading text, the paragraphs, lists and quotes you write in Markdown, along with ledes and the hero's description, is in Source Serif 4, a step larger and held to a comfortable line length. Each comes in two weights, regular and bold, and the serif in italic too.

Both fonts ship with Canopy and are served from your own site, next to its stylesheet, so a visitor's browser asks no one else for them. They are licensed under the SIL Open Font License, which travels with them.

To use other fonts, set them in @layer properties in app/styles/index.css. Headings take --canopy-font-display and reading text --canopy-font-body; set --canopy-font-body: var(--font-sans) for one family throughout.

app/styles/index.css
@layer properties {  :root,  :host {    --font-sans: "Inter", system-ui, "Segoe UI", Helvetica, Arial, sans-serif;    --font-serif: Georgia, "Times New Roman", serif;    --default-font-family: var(--font-sans);    --canopy-font-body: var(--font-serif);  }}

A font Canopy doesn't ship needs its files on the page. Self-host them under assets/ with an @font-face rule, or link a service such as Google Fonts in content/_app.mdx's head:

content/_app.mdx
export function Head() {  return (    <>      <Meta siteTitle="Manu's Great Flood" />      <Stylesheet />      <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />      <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet" />    </>  );}

A site made with Canopy 1.x keeps its own fonts: its app/styles/index.css sets them, after Canopy's.

Shape

Canopy's corners are rounded (4, 8, 12 and 16px), its cards and panels lifted with soft shadows, and its focus ring a two-tone outline in your accent. Each is a token, so one line restyles every component:

app/styles/custom.css
@layer properties {  :root,  :host {    /* Square corners */    --canopy-radius-sm: 0;    --canopy-radius-md: 0;    --canopy-radius-lg: 0;    --canopy-radius-xl: 0;    --canopy-radius-pill: 0;    /* No shadows: a zero shadow, which Canopy can combine with an edge */    --canopy-shadow-sm: 0 0 #0000;    --canopy-shadow-md: 0 0 #0000;    --canopy-shadow-lg: 0 0 #0000;  }}
TokenWhat it styles
--canopy-radius-sm … --canopy-radius-xl, --canopy-radius-pillCorners, from small controls to the hero's card; pills are search fields and round controls
--canopy-surface, --canopy-surface-raisedA panel's fill, and a card's
--canopy-card-shadow, --canopy-shadow-sm … lgA card's hairline and lift, and other shadows
--canopy-control-edgeA field's and an outline button's edge, 3:1 against the page
--canopy-container-content, --canopy-container-wideThe page's column (<Container>, 75rem) and the wide one (variant="wide", the hero's, 90rem)
--canopy-focus-color, --canopy-focus-width, --canopy-focus-offsetThe focus ring

Keep a color you set at its ratio: 4.5:1 for text, 3:1 for a control's edge and the focus ring.

Styling

Implementers can easily customize their Canopy projects by adding their own CSS rules that extend or override the default styles. Many Canopy components accept className and other valid HTML attributes so you can apply scoped changes without overriding the global theme. You can author these in your custom CSS files that extend the base styles.

First, ensure your custom CSS files are imported in the main stylesheet (app/styles/index.css):

app/styles/index.css
@import "tailwindcss";@import "@nulib/canopy/ui/styles/index.css";@import "./custom.css";

CSS Variables

You can then add your own CSS rules in app/styles/custom.css or new files you import to extend or override existing styles. This can include modifying CSS variables, adding new classes, or defining more complex selectors. For example, a Northwestern University digital project might include the following customizations to match institutional brand.

app/styles/custom.css
/* Northwestern Brand *//* https://www.northwestern.edu/brand/visual-identity/color-palettes/ */ @layer properties {  :root,  :host {    /* Northwestern Purple */    --color-accent-50: #ffffff;    --color-accent-100: #e4e0ee; /* Purple 10 */    --color-accent-200: #ccc4df; /* Purple 20 */    --color-accent-300: #b6acd1; /* Purple 30 */    --color-accent-400: #a495c3; /* Purple 40 */    --color-accent-500: #9380b6; /* Purple 50 */    --color-accent-600: #765da0; /* Purple 70 */    --color-accent-700: #4e2a84; /* Northwestern Purple */    --color-accent-800: #401f68; /* Purple 120 */    --color-accent-900: #200b48; /* Purple 160 */     /* Northwestern Rich Black */    --color-gray-50: #ffffff;    --color-gray-100: #d8d6d6; /* Rich Black 10% */    --color-gray-200: #bbb8b8; /* Rich Black 20% */    --color-gray-300: #a29f9e; /* Rich Black 30% */    --color-gray-400: #8a8585; /* Rich Black 40% */    --color-gray-500: #716c6b; /* Rich Black 50% */    --color-gray-600: #484342; /* Rich Black 70% */    --color-gray-700: #342f2e; /* Rich Black 80% */    --color-gray-800: #1a1817; /* Rich Black 90% */    --color-gray-900: #000000; /* Rich Black */     /* Additional Variables */    --color-northwestern-purple: var(--color-accent-700);    --color-accent-default: var(--color-northwestern-purple);    --color-gray-default: var(--color-gray-900);    --color-gray-muted: var(--color-gray-700);  }}

Override order

Canopy generates the --color-* and --clover-* tokens from canopy.yml and places them at the start of your compiled stylesheet, inside @layer properties. Everything in app/styles/index.css, including imported files like custom.css, comes after the generated tokens. A token you redefine inside @layer properties, or in a rule outside any layer, therefore takes precedence. This works the same in npm run dev and npm run build, and you don't need !important. Tokens you don't redefine keep the values generated from canopy.yml.

app/styles/custom.css
@layer properties {  :root,  :host {    /* Texas A&M Maroon */    --color-accent-700: #6d0000;    --color-accent-800: #500000;    --color-accent-900: #300000;    --color-accent-default: #500000;  }}

Upgrading from 1.13.1 or earlier: Older releases appended the generated tokens after your stylesheet, so overrides inside @layer properties needed !important to take effect in production builds. Existing !important declarations keep working, and you can remove them once you upgrade.

A primary button under the pointer takes --color-accent-hover, which Canopy mixes from --color-accent-default (20% toward black, or toward white in dark mode). It follows your own --color-accent-default, so the examples above get a hover in their own color. Set --color-accent-hover too for a hover color of your choosing, and keep the button's label at 4.5:1 on it.

Upgrading from 1.x: a primary button's hover used to be --color-accent-600. That step's label fell under 4.5:1 for most palettes, so Canopy 2 darkens the button on hover instead.

Tailwind

Canopy compiles app/styles/index.css with Tailwind CSS v4, which you configure in CSS rather than in a JavaScript config file:

  • @theme adds design tokens and the utilities that use them. Tailwind's built-in scales, such as spacing and font sizes, stay available. Its gray utilities, such as text-gray-700 and bg-gray-100, use your grayColor palette.
  • @theme inline creates utilities that point at an existing variable, such as a Canopy token, so they follow your theme.
  • @utility defines a custom utility, @plugin loads a Tailwind plugin package, and @source adds files for Tailwind to scan for class names.
app/styles/index.css
@import "tailwindcss";@import "@nulib/canopy/ui/styles/index.css";@import "./custom.css"; @theme {  --font-heading: "Fraunces", Georgia, serif; /* font-heading */} @theme inline {  --color-brand: var(--color-accent-default); /* bg-brand, text-brand */} @utility max-w-content {  max-width: 1080px;}

Tailwind's theme layer sits below Canopy's tokens, so @theme can't change a token Canopy already sets, such as --color-gray-500 or a font you set in @layer properties. Override those in @layer properties instead, as shown in Override order.

If you need a JavaScript config, for example for a plugin that only ships in that form, load your own with @config "./tailwind.config.js"; in app/styles/index.css. Earlier templates included a generated app/styles/tailwind.config.cjs; Tailwind v4 never loads it, so you can delete it. The @nulib/canopy/ui/tailwind-config helper it used is deprecated and will be removed in the next major release.

Clover Component overrides

The Image, Viewer, Slider, and Scroll components (drawn by Clover) read their own --clover-* CSS variables. Canopy sets these for you from the theme tokens above, so Clover components follow your canopy.yml palette and any overrides you make to --color-accent-* or --color-gray-*.

Clover variableCanopy tokenUsed for
--clover-color-accent--color-accent-defaultButtons and active states
--clover-color-accent-alt--color-accent-900Clover 3 only: button hover states
--clover-color-primary--color-gray-defaultText
--clover-color-primary-alt--color-gray-900Clover 3 only: media player, headings
--clover-color-primary-muted--color-gray-mutedPlaceholders and muted text
--clover-color-secondary--color-gray-50Panel backgrounds, text on accent buttons
--clover-color-secondary-alt--color-gray-400Resize handles, popover arrows
--clover-color-secondary-muted--color-gray-300Subtle borders
--clover-radius--canopy-radius-smCorner radius (4px)
--clover-radius-pill--canopy-radius-pillPill buttons

To give Clover components different colors from the rest of your site, set the --clover-* variables directly. Target :root to change every Clover component, or a component class such as .clover-viewer or .canopy-slider to scope the change. These overrides don't need !important.

app/styles/custom.css
/* Clover IIIF theme overrides */.clover-viewer,.canopy-slider {  --clover-color-accent: #500000;  --clover-color-accent-alt: #300000;}

Overrides

You can also override existing styles by targeting specific classes. For example, to modify the default button styles across your project, you can add the following CSS rules:

app/styles/custom.css
/* overrides default button styling */.canopy-button {  border-radius: 0;}
<Button href="/search" label="Browse Works" />
Browse Works

Custom classes

Implementers can easily add their own custom CSS classes like custom-button to modify button styles.

app/styles/custom.css
/* adds custom soft button styling */.custom-button {  font-weight: 700;  background: linear-gradient(    135deg,    var(--color-accent-50) 0%,    var(--color-accent-200)  );  color: var(--color-accent-800);  border: 2px solid var(--color-accent-300);  box-shadow: 2px 2px 5px var(--color-accent-200);}
<Button className="custom-button" href="/bibliography" label="Bibliography" />
Bibliography

Complex selectors

You can also extend existing button classes by explicitly defining new selectors like this example with the added data-color="crimson" attribute. Keep the button's label at a contrast ratio of 4.5:1 on each fill: white on #cb1d63 is 5.3:1, and on the hover's #ab1251, 7:1.

app/styles/custom.css
/* adds custom crimson shaded button */.canopy-button[data-color="crimson"] {  background-color: #cb1d63;   &:hover,  &:focus {    background-color: #ab1251;  }}
<Button data-color="crimson" href="/exhibit" label="Explore Exhibit" />
Explore Exhibit