Core Concepts
This page is the shortest version of the Boss CSS mental model.
The three layers
Boss is easiest to reason about when you separate these layers:
- Authoring inputs
$$JSX props- Static
className/classtokens
- Output strategies
inline-firstclassname-firstclassname-onlyruntime
- Build modes
- PostCSS
npx boss-css build/watch- optional
npx boss-css compile
Most confusion comes from mixing those layers together. Strategy answers “what kind of output do I want?”. Build mode answers “how do I generate or rewrite that output?”.
The pipeline, in 30 seconds
- Config is loaded from
.bo$$/config.jsplus optionalpackage.jsonoverrides. - Parsers read your chosen authoring inputs and build a normalized prop tree.
- Prop plugins handle CSS props, selectors, tokens, and other features.
- The selected strategy decides what becomes inline styles, class rules, runtime work, or browser-injected CSS.
- Boss writes generated CSS and, when needed, generated runtime files.
See Plugin Pipeline.
Authoring inputs
$$JSX props are the primary component authoring surface.- Static
className/classtokens are the static string authoring surface. - You can mix both in many build flows, but not every strategy supports every input:
classname-onlyis the static className lane.runtime.onlydisables className parsing.compilecurrently rewrites JSX only.
Output strategies
inline-first: base JSX props prefer inline styles; nested contexts become CSS rules.classname-first: static JSX props prefer generated class rules; dynamic values must be functions.classname-only: parse static class strings into CSS and skip generated runtime files.runtime: use the runtime strategy wrapper for runtime-only or hybrid browser evaluation.
See Strategies.
Build modes
- PostCSS /
build/watchgenerate CSS and, when needed, generated runtime files. compileis optional. It rewrites supported JSX source after you already chose a strategy.
Compile currently supports JSX with inline-first and classname-first. It is not a fifth strategy.
Generated runtime vs runtime strategy vs compile
These terms are related but different:
- Generated runtime:
.bo$$/index.jsand.bo$$/index.d.ts. - Runtime strategy: the
runtimestrategy plugin that runs styles in the browser in runtime-only or hybrid mode. - Compile: the optional source-rewrite step run with
npx boss-css compile.
If those three are clear, the rest of the docs become much easier to follow.
Tokens
Tokens are typed from config and are available through $$.token.
See Tokens.