inspectCssTheme
inspectCssTheme reads a stylesheet and tells you what its color theme is made of: which kind of theme it is, which modes it covers, what the brand color is, and what a complete theme would still need. Use it before you change a theme, so the change fits the file you already have.
Example
import { inspectCssTheme } from 'colore-js';
const css = `:root {
--bg: #ffffff;
--text: #17212b;
--brand: #4f46e5;
}`;
const theme = inspectCssTheme(css);
console.log(theme.kind, theme.format, theme.modes.join(', '));
console.log(theme.brand?.token, theme.brand?.hex, theme.brand?.look);
console.log(theme.missing);
css-variables hex light
--brand #4f46e5 common-default
[ 'dark mode', 'success and warning colors (optional)' ]
The indigo matches Colore’s common-default category. The report also shows that the stylesheet has only a light theme.
Syntax
inspectCssTheme(css: string): ThemeReport
Parameters
Returns
A ThemeReport:
brand.look is 'neutral' for a gray brand or an untouched shadcn/ui primary from any base color, Slate and Gray included, 'common-default' for a saturated indigo to purple brand, and 'custom' for anything else.
Usage
Token groups are the same ones applyThemeToCss and adjustCssVariables accept, so the report tells you exactly which group to change. To check contrast in the same file, use auditCssVariables.
The Colore CLI runs this check across a whole project with colore inspect, and also lists colors hard-coded in components.