Chroma-Style
@chroma/style — design tokens, tw() class merging, prose typography and cva presets for Chroma apps; its utility CSS generator is the native chroma-style build plugin of the Chroma CLI.
Chroma-Style (@chroma/style, plugin name chroma-style) is how Chroma apps get a shared visual language without npm, without a CSS toolchain. It ships as a browser plugin plus a build plugin inside the CLI, in three parts:
- Tokens — shadcn-compatible CSS variables (
--background,--primary,--radius…), light and dark. - A generator — the native
chroma-stylebuild plugin of the Chroma CLI (no Node, no script in your project) that scans your.chr/.htmlfiles for class names and emits only the CSS those classes need, layered and readable. - Runtime helpers —
twMerge()/tw()to merge classes with conflict resolution, andcvapresets (button,badge,card,input) built on the WASM engine'scvaandcx.
Problem it solves: Chroma UI is plain DOM nodes with class strings. Chroma-Style gives those strings a vocabulary (flex items-center gap-4 md:grid-cols-3 hover:bg-primary/80) that the generator turns into a small, ordered stylesheet — and that twMerge() can override in components, the way shadcn's cn() does.
| Plugin name | chroma-style |
| Package | @chroma/style (v0.3.0) |
loadAs key | plugins.style from loadPlugins() |
| License | GPL-3.0-or-later — © Targ Apps |
What is in the package
| Artifact | Purpose |
|---|---|
tokens.css | Light/dark palettes, semantic colors, radius scale, fonts, text scale, shadows, motion variables (layer tokens) |
base.css | Reset and base styles (layer base) |
lib/ | The class grammar in JavaScript: tw.js uses it in the browser to know which CSS properties a class sets. The build-time generator is the native chroma-style build plugin — Utilities |
tw.js | twMerge() / tw() — class merge with conflict resolution |
prose.css | Typography for long-form content (prose, `prose-sm |
animate.css | @keyframes (spin, marquee, accordion, enter/exit…), included only when a class references them |
components.css | cs-* shells, focus-ring, is-disabled, [data-animate] hooks |
utilities.css | Generated starter subset for apps that do not use the generator |
variants.js | createVariants(cva) → button, badge, card, input |
index.js | bootstrapStyle, injectStyles, twMerge, tw, createTw, utilityClasses, default plugin export |
chroma.plugin.json | Manifest (loadAs: "style", hooks.styles) |
Quick start
// chroma.json (excerpt)
{ "plugins": ["chroma-style"] }// src/main.chr
import { render, cva, cx } from "../pkg/chroma.js";
import { bootstrapStyle } from "../plugins/chroma-style/index.js";
import { App } from "./App.chr";
// styles:false — the HTML already links the CSS generated by the chroma-style build plugin
globalThis.__chromaStyle = bootstrapStyle({ cva, cx, styles: false });
render(App, document.getElementById("app"));{
"plugins": ["chroma-style"],
"pluginOptions": { "chroma-style": { "src": ["src", "index.html"], "output": "assets/css/app.css" } }
}chroma dev and chroma build generate assets/css/app.css (link it from index.html); see chroma-style build plugin.
// Any component
const { presets, tw } = globalThis.__chromaStyle;
e("button", { class: presets.button({ variant: "primary", size: "sm" }) }, "Save");
e("p", { class: tw("text-muted-foreground text-sm", props.class) }, "Caption");End-to-end narrative, patterns, and troubleshooting: Styling guide. A real app built this way: Targ Apps in Chroma — Styles.
Documentation map
| Page | Contents |
|---|---|
| As a plugin | Manifest, loader styles hook, vendoring, how chroma build treats the plugin, the CSS build step |
| Tokens | Brand --cs-* layer, semantic tokens, scales, light/dark theming |
| Utilities | The generator: CLI, utility grammar, variants, prose, animations, twMerge, extending |
| Presets | Variant tables and composition patterns |
| Runtime hosts | Portable (Web) vs Executable (Desktop) for CSS |
When to reach for something else
- Large component libraries — Chroma-Style gives you tokens, utilities and four presets; shadcn-style components (
button.chr,badge.chr…) are written in your app withcva+twMerge. - Global animation libraries — Use legacy libraries (CDN UMD) or vendored ESM (GSAP) with the
[data-animate]hooks andanimate-*classes; there is no npm CSS pipeline.
Next
- Styling guide
- Plugins
- Components — cva
- Runtime modes
- chroma-style by mode — matrix row (Portable vs Executable)