Theming from a brand hex¶
Most products arrive with a hue still free, and nilam solves the rest from that one number. Some arrive with the colour already chosen: a logo, a tile, a printed card. For those, pass the hex.
import { solvePalette, solveSemanticHues, hexToOklch } from 'nilam';
const solid = hexToOklch('#1634C2');
const hue = Math.round(solid.h * 10) / 10;
const { hues } = solveSemanticHues(hue, { solid });
const palette = solvePalette(hue, { semanticHues: hues, solid });
What the hex does¶
- Its hue drives the whole palette. Neutrals, the brand scale and the semantic
search all run at that hue, exactly as
npx nilam 265.9would. - In light mode it becomes step 9, the solid: the filled button, the link, the brand moment. The logo and the button are then one colour, which is the point.
- In dark mode it does not. Step 9 stays on the glow band, L 0.66. A saturated brand is almost always dark, and #1634C2 on a dark page is 1.6:1: not a glow, a hole.
Checked, not trusted¶
The pin must meet the two contracts every solved solid meets: visible on the page at
3.05:1, and carrying its own label at 4.55:1. A hex that fails either comes back
unsatisfiable, and the prover fails the build by name. A pale brand such as #9fb4ff
fails this way; that case is in the test suite.
How the big systems do it¶
| System | What happens to your hex |
|---|---|
| Material 3 | The seed sets the hue; tones set the value. The default variant lowers chroma, so the hex often never appears. Primary is tone 40 in light and 80 in dark. |
| Radix | "Override step 9 of your accent scale with your brand color." |
| nilam | Radix's rule in light, Material's polarity rule in dark, both proven. |
What it measured, for #1634C2¶
The derived solid at this hue is #3d6af5, L 0.575, and it collapses with ok under tritanopia at 0.0773 against a floor of 0.09. Pinned, the separation is 0.1997 and the light-mode brand collapse is gone. The dark glow still collapses with ok under tritanopia, as every blue does, so ok components there carry a glyph, which the prover already requires.