Skip to Content

Colors

Clover’s colors are custom properties your page can set. Try yours below, and watch each contrast pass or fail.

Contrast guide

Pick a palette, change any color, and copy the CSS the guide writes. Text requires 4.5:1 (WCAG 1.4.3), and so do the round controls’ glyphs, since Exit full screen’s label shares their colors. Rings and the marks of a state require 3:1 (1.4.11).

Palette
Text
Quieter text
Ground
Hairlines, hover fills
Popover words, closed headings
Rings, selection
Links
Control fill
Control glyph

All 11 required contrasts pass, 1 only just: Accent text under the pointer.

ColorsContrastRequiresResult
Textprimary on secondaryThe Panel, menus, popups, fields16.95:14.5:1Passes
Quieter textprimary-muted on secondaryDescriptions, status, field edges14.63:14.5:1Passes
Text under the pointerprimary or primary-muted on secondary-mutedRows and menu options11.92:14.5:1Passes
Quieter text in a popoversecondary-alt on primaryA chapter's title on the seek bar, a place's date on the Map10.02:14.5:1Passes
Placeholderprimary 65% into secondarySearch's field5.27:14.5:1Passes
Accent textaccent-text on secondaryLinks, Read more, the selected item's label5.75:14.5:1Passes
Accent text under the pointeraccent-text on secondary-mutedA link in a row or a menu4.68:14.5:1Just passes
Ringsaccent against secondaryFocus, the selected item, the current tab5.75:13:1Passes
Ring under the pointeraccent at half strength against secondaryA preview: pressing decides2.24:1None—
Control glyphscontrol-glyph on controlThe round controls, Exit full screen16.95:14.5:1Passes
Glyphs on the accentcontrol-glyph on accentA control under the pointer or focused5.75:14.5:1Passes
Hairlinessecondary-muted against secondaryBetween regions: they mark nothing1.22:1None—
Closed heading's linesecondary-alt at half strength against secondaryUnder a closed heading in the Panel: its chevron marks it1.28:1None—
Over a pictureprimary beside secondaryHotspots, focus over images: one tone keeps 3:1 on any picture16.95:19:1Passes
/* Clover's own colors: nothing to set. */

Setting colors

Each color is a custom property named --clover-color- plus its name in the guide. Variables lists each with what it colors.

.my-layout { --clover-color-accent: #4e2a84; --clover-color-secondary: #fafafa; }

The round controls keep their dark fill (control) and white glyphs (control-glyph) in a dark mode, since they sit over the picture.

The media player’s colors are --clover-player-*, and the Canvas’s background is --clover-canvas-background.

Checklist

Clover’s default colors meet WCAG 2.2 AA (open gaps are in ACCESSIBILITY.md ). Yours are up to you: check them here, and again for a dark mode.

High contrast

An accent too light to carry white text at 4.5:1, such as an orange, a yellow or a light blue, can still be yours. Set highContrasthigh-contrast on the Viewer<clover-viewer>, the Root<clover-root>, or a component that stands alone:

<Viewer iiifContent={url} highContrast />
<clover-viewer iiif-content="https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json" high-contrast></clover-viewer>

The accent then goes only where nothing is read on it: rings, outlines, the line under an open heading, the marks of a state. Where it would fill behind a glyph or words, the round controls’ dark fill stands in: control-glyph on control. Under the pointer, the accent rings the control at half strength, 1px clear, as Items rings an item, and in full once it’s chosen (the language read, a menu open). Focus keeps its own ring. Text in the accent is your accent-text if you set one, else the text’s own color.

Clover turns high contrast on wherever the system asks for more contrast (prefers-contrast: more), whatever your page sets.

Do

  • Set secondary to your page’s background: most components paint no ground of their own, so Clover’s text sits on your page.
  • Size your page in rem or %, never pixels on its root, so Clover follows the browser’s text size.
  • Give a dark mode a lighter accent-text, and keep accent for rings and fills.
  • When you restyle a state, keep a second sign beside the accent, as Clover does: a bold label, an underline, a second ring.
  • Measure what your page shows, and never round a ratio up: 4.49:1 fails.

Don’t

  • Don’t mark a state with the accent alone (WCAG 1.4.1).
  • Don’t swap control and control-glyph for a dark mode.
  • Don’t let a reset take the markers off Clover’s lists, or put them back.
  • Don’t bring back the Body’s motion where the system asks for reduced motion.
  • Don’t set a --clover-* property that Variables doesn’t list: Clover sets those itself.