ExtantApe

payload plugin color theory

by ExtantApe
Admin customization
v3
^3.80.0
MIT

Overview

Summary generated from the README

Adds a Color themes collection, a Color theory global and CSS endpoints to Payload. Editors build a theme from a few hex colors using OKLCH-based harmonies, and the plugin generates light and dark CSS variables for the site and optionally the Payload admin. Colors are adjusted to meet WCAG AA, or kept exact with warnings. Requires Payload 3.80 or later, @payloadcms/ui and React 19.

Features

  • Harmonies: monochromatic, analogous, complementary, split complementary, triadic, tetradic and square
  • Live UI kit in the editor with a WCAG contrast table and suggested accessible alternatives
  • Generates palette CSS variables for light and dark from a theme served by CSS endpoints
  • Optionally themes the Payload admin through its own color variables
  • Auto, Light and Dark mode script, provider, hook and selector component
  • JSON import and export with hex values, plus built-in presets and brand intensity levels

Use cases

  • Create an accessible brand theme for a site from one base color and a harmony rule
  • Let editors switch the website between light, dark and device-following modes
  • Restyle the Payload admin panel to match a brand palette while keeping its dark mode

From the author

Color Theory for Payload: build site and admin themes from color harmonies (complementary, triadic, tetradic and more), with contrast checked in light and dark, an Auto, Light and Dark switch, and JSON import and export with hex values.

Installation

npm i @extantape/payload-plugin-color-theory

0

Stars

0

Forks

0

Open Issues

1 weeks ago

Last Updated

146

Weekly Downloads

v0.1.1

npm Version

87.2 KB

Unpacked Size

0

Dependencies

GitHub stars

00 since Nov 8

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20260
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
npm weekly downloads

146+146 since Nov 11

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026146
Dec 5, 2026185
Dec 4, 2026355
Dec 3, 2026384
Dec 2, 2026411
Dec 1, 2026437
Nov 30, 2026474
Nov 29, 2026554
Nov 28, 2026534
Nov 27, 2026372
Nov 26, 2026345
Nov 25, 2026334
Nov 24, 2026498
Nov 23, 2026462
Nov 22, 2026537
Nov 21, 2026508
Nov 20, 2026493
Nov 19, 2026462
Nov 18, 2026429
Nov 17, 2026205
Nov 16, 2026190
Nov 15, 20260
Nov 14, 2026298
Nov 13, 2026254
Nov 12, 20260
Nov 11, 20260

Each point is npm's rolling 7-day download count.

Health Score

74/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1452135444-root.svg)](https://payloaddirectory.dev/plugins/1452135444-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1452135444-root"><img src="https://payloaddirectory.dev/badge/1452135444-root.svg" alt="Payload Directory"></a>
Updated Nov 29, 2026Created Nov 10, 2026Published Nov 15, 2026

README

payload-plugin-color-theory

Color Theory for Payload: build site and admin themes from color harmonies (complementary, triadic, tetradic and more), with contrast checked in light and dark, an Auto, Light and Dark switch, and JSON import and export with hex values.

Status: early, 0.x. 38 tests pass. Tried on a local copy of a real site in Chromium, light and dark:

  • the editor works: presets, harmonies, import, export and save;
  • the admin takes on a saved theme's colors;
  • axe finds no contrast problems in anything this plugin draws.

It hasn't been used on a live site yet. On a local copy of a real site (Chromium, light and dark, desktop and phone), the light/dark switch, Bold brand intensity, the header and its menus passed axe on eight pages. The editor's UI kit and the exact-colors warnings have only been tested in jsdom so far.

What it does

  • Harmonies. From one base color: monochromatic, analogous, complementary, split complementary, triadic, tetradic (rectangle) and square. Hues are rotated in OKLCH, a perceptual color space, so the results look equally light and belong together.

  • Themes from a few colors. A theme is a name and a handful of hex colors: primary, secondary, accent, a neutral (the color grays lean toward), and optionally success, warning and error.

  • Tokens for the site. --palette-* variables for light and dark: surfaces, text, borders, and for each role a fill, the text on it, a readable text shade and a soft background.

  • Payload's admin, too. It gets its own --color-base-*, success, warning and error scales, the variables Payload is themed with, so the admin's own dark mode keeps working. Off until you turn it on.

  • Readable by construction. Text passes WCAG AA (4.5:1) on every surface it can sit on: the page, cards, sunken areas and its own soft badge background. Fills stand out from the page (3:1). A brand color that doesn't pass is moved in lightness only, keeping its hue. The editor shows every pair with its ratio.

  • Light, dark and Auto. The CSS follows data-theme="light|dark" on <html>. With no choice saved, it follows the device. @extantape/payload-plugin-color-theory/mode has the pieces a site needs:

    • colorModeScript(): an inline script for <head>, so the page never flashes the wrong mode. Import it from the main entry or @extantape/payload-plugin-color-theory/mode/script, neither of which is a client module, so a server layout can call it. The /mode entry is a client module and also re-exports it, but a server component can't call it from there;
    • ColorModeProvider and useColorMode(): in Auto, these follow the device live;
    • ColorModeSelector: an Auto / Light / Dark select you can label in any language.

    The choice is stored under payload-theme, the key Payload's website template uses, so choices people already made carry over.

  • Brand intensity. One setting for how much of the site carries the brand colors: Off, Subtle, Balanced or Bold (the default). Each level turns on more kinds of element: Subtle colors button fills; Balanced adds the header and badge colors; Bold adds the thin bands on cards and the washes behind page intros. Any kind can be set to always on or always off. The site reads them as tokens (--palette-button, --palette-header, --palette-header-rule, --palette-badge-*, --palette-band, --palette-wash), so it needs no settings code. Every level passes WCAG AA (tested).

  • Adjust, or keep my exact colors. By default colors are adjusted for accessibility. Switch a theme to "Use my exact colors" and nothing is moved: the editor marks what falls short and offers the nearest passing color, but saving still works.

  • A live UI kit in the editor. A header, buttons, links, a card with its band, badges, a form field and an alert, in light and dark side by side, updated as you change colors. A red mark sits on any element that fails WCAG AA; open it for "Better for accessibility: #xxxxxx" and a "Use this" button. Under the kit, a live WCAG table (closed by default) gives each pair's ratio, graded AAA, AA, "AA, close" or Fails in color and in words; choosing a row points at that element. The result is announced politely once you pause.

  • Import and export. Themes are plain JSON with hex values (format: "color-theory/1"). Import checks every field and says what's wrong. The admin refuses to save a theme that wouldn't import.

  • Presets: Field Guide, Terracotta, Rainforest, Reef, Desert bloom, Night market, High contrast. Each passes contrast in light and dark.

{
  "format": "color-theory/1",
  "name": "Field Guide",
  "colors": { "primary": "#cf8137", "secondary": "#e48185", "accent": "#5a8f6b", "neutral": "#3b2a26" },
  "radius": { "md": 8, "lg": 14 }
}

On its own, and with others

On its own. Color Theory needs only Payload. It adds its own collection, global and CSS endpoints, and your site links the CSS. It doesn't use any other plugin.

Needs. Payload ^3.80.0, @payloadcms/ui ^3.80.0 and React ^19.0.0 as peer dependencies. No other EXTANT APE plugin is required.

Works with:

  • Nested Docs Browser (@extantape/payload-plugin-nested-docs-browser): the browser's --ndb-* variables fall back to the --palette-* tokens Color Theory writes, so it picks up the site's theme with nothing to set. Neither imports the other. Only the token names are shared.
  • Polyglot (@extantape/payload-plugin-polyglot): the language picker and the translation notice fall back to the same --palette-* tokens.
  • Admin screens of other plugins: with applyToAdmin on, any plugin whose admin screens use Payload's --theme-* colors follows your palette there too. Each plugin's README says whether it does.

Family. Color Theory is in the Theme family, with Stock Images, which is named but not built yet. The families are a working draft that may change.

Install

npm install @extantape/payload-plugin-color-theory
// payload.config.ts
import { colorTheory } from '@extantape/payload-plugin-color-theory'

plugins: [
  colorTheory({
    access: ({ req }) => req.user?.role === 'admin', // who may save and choose themes; required
    adminGroup: 'Design',
  }),
]

This adds:

  • a Color themes collection with the editor;
  • a Color theory global, which picks the theme in use and whether it applies to the site, the admin or both;
  • three endpoints: /api/color-theory/theme.css, /api/color-theory/admin.css and /api/color-theory/presets.

The CSS is sent with an ETag and no-cache. A change shows on the next page load, and an unchanged theme costs a 304. Everyone may read themes, because they're only colors.

On the site, link the CSS and add the mode script:

import { colorModeScript } from '@extantape/payload-plugin-color-theory' // server-safe
import { ColorModeProvider, ColorModeSelector } from '@extantape/payload-plugin-color-theory/mode' // client

<html suppressHydrationWarning>
  <head>
    <script dangerouslySetInnerHTML={{ __html: colorModeScript() }} />
    <link rel="stylesheet" href="/api/color-theory/theme.css" />
  </head>
  <body>
    <ColorModeProvider>
      <ColorModeSelector />
      {children}
    </ColorModeProvider>
  </body>
</html>

Or render the CSS on the server with activeThemeCss(payload). The selector has the classes ct-mode, ct-mode__label and ct-mode__select, plus data-mode and data-resolved for styling.

Limits

  • Payload's own admin uses gray step 500 on step 100 for a few small labels, such as the locale switcher. That pair is under 4.5:1 with Payload's default grays as well, and this plugin doesn't change which steps Payload uses.
  • One theme is in use at a time, across the whole install. Per-site themes for multi-tenant setups aren't built.
  • Colors are adjusted in lightness only. A hue you pick is kept, even when another hue would contrast better.

Commands

npm test          # Vitest
npm run typecheck
npm run build

License

MIT. See LICENSE.

Similar plugins