ernestdefoe / livery
Colors for every Flarum tag: generate a palette for all of them at once, readable text on every color, and dark-mode colors, with a preview and undo.
Package info
Language:TypeScript
Type:flarum-extension
pkg:composer/ernestdefoe/livery
Fund package maintenance!
Requires
- php: ^8.3
- flarum/core: ^2.0
- flarum/tags: ^2.0
Requires (Dev)
- flarum/phpstan: ^2.0
- flarum/testing: ^2.0
Suggests
- ernestdefoe/bespoke: Offers Bespoke's brand color as a starting point for tag palettes.
Provides
None
Conflicts
None
Replaces
None
README
Colors for every Flarum tag, readable in light and dark.
Pick a starting color and a scheme, and Livery colors every tag at once: you see each tag before and after, in light and dark mode, before anything is saved, and the change can be undone. Each tag also gets readable text, its own dark-mode color if you want one, and a lock.
What it does
- Color every tag at once. Start from your forum's primary or secondary color, Bespoke's brand color, or any color you pick. Choose a scheme: Spread (the most distinct colors, however many tags you have), Analogous, Complementary, Triadic, One hue or Random. Shuffle until you like it.
- Child tags shaded from their parent, so a category and its subtags read as a family.
- Preview before you save. Every tag as it is now, and as it will be in light and dark mode, with the text contrast of each label.
- Undo. Apply is one change, and the last five changes can be undone, newest first.
- Lock a tag to keep its colors when you recolor the rest.
- Readable text on every tag. Flarum picks black or white text with a quick brightness formula that leaves text too faint on many mid-tone colors: on
#e74c3cred it picks white at 3.8:1, under the 4.5:1 that readable text needs. Livery picks by real contrast (WCAG), so every label reads. A tag can also have its own text color. - Dark mode colors. Leave tags as they are in dark mode (Flarum's default), let Livery soften each one so it sits well on a dark page, or give a tag a dark color of its own.

- In the Edit Tag dialog: Random, Light and Dark color buttons, the text and dark-mode choices, the lock, and a live preview on a light and a dark page, with an Adjust the color button when the text is hard to read.
Settings
Administration → Livery:
| Setting | Default | |
|---|---|---|
| Tag colors in dark mode | Same as light | Adjust automatically softens every tag for dark pages. A tag can choose for itself. |
| Readable tag text | On | Picks text by contrast. Turn it off to keep Flarum's own pick. |
Works with everything that draws a tag
Livery doesn't restyle tags itself. It gives every tag its dark-mode color through the tag's own color, so Flarum's labels, tiles and heroes, and other extensions and themes that use a tag's color (Bespoke, Concourse, Postcards, Colored…), all follow it without knowing Livery is there. Text colors go into one small stylesheet, only for tags whose text needs changing, and only for tags the visitor has already loaded.
For themes and extensions
--tag-textis set on[data-tag-vars="<slug>"]for every colored tag Livery has drawn: the readable text color for the tag's current background. Usecolor: var(--tag-text, <your own>)on anything you fill with a tag's color.[data-livery="<slug>"]marks a tag's hero, a discussion's hero and the tag's New Discussion button.- The tag resource carries
liveryColorDark(#rrggbb,auto,sameor null for the forum default),liveryTextColorandliveryTextColorDark(#rrggbbor null for automatic), andliveryLockedfor admins.
Good to know
- Flarum's own Color field stays the source of truth for light mode. Remove Livery and every tag keeps its colors.
- Every color is checked to be a six-digit hex color before it is saved, since colors end up in a stylesheet.
- Light. The forum gets under 3 KB of JavaScript (gzipped) and no CSS file. Livery's values for every tag on a page come in one small query, however many tags there are.
- Requires Flarum 2,
flarum/tagsand PHP 8.3.
Moving from Tags Color Generator
Livery succeeds Tags Color Generator by Nearata, which brought random tag colors to Flarum 1. Thank you, Nearata. It stored only Flarum's own tag color, so there is nothing to migrate:
composer remove nearata/flarum-ext-tags-color-generator composer require ernestdefoe/livery php flarum migrate php flarum cache:clear
Installation
composer require ernestdefoe/livery php flarum migrate php flarum cache:clear
Then enable Livery in the admin panel.
Updating
composer update ernestdefoe/livery php flarum migrate php flarum cache:clear
Support
Questions and bug reports: ernestdefoe.online.
☕ If you like the things I have built, consider buying me a coffee.
Licence
MIT.


