Overview
Design tokens (CSS variables) for fonts, colors, spacing, layout, and component styling CSS rules for the base document and component modules (e.g. headings, tables, citations) Translation hooks that map tokens to non-web outputs (plots, Word, email, PDF)
Resolution and Computation
Resolution order (when no theme is specified): workspace theme.css(walks up from the document path), then user default.css, then builtin stencila.css. Named themes : if you request a theme by name, Stencila searches user themes first, then builtin themes. Plot presets : if --plot-themeis set to a named preset (not customor none), preset CSS from themes/plots/{name}.cssis merged into the theme before variables are extracted. Token extraction scope : only top-level :rootcustom properties are parsed for token export. Tokens inside @media/ @supportsblocks are used for web rendering but are not exported to non-web targets. Evaluation and conversion : var()references and calc()/ color-mix()expressions are resolved, colors are normalized to hex, and lengths are converted to the target unit system (points, pixels, inches, or twips). Runtime overrides : computed variables can be merged with document metadata overrides (e.g. --document-*) for features like margin box content. Caching and watching : theme resolution is cached for ~30 seconds in the runtime; tooling that needs immediate updates uses the watch API to reload on file changes.
Usage
--text-font-family, --heading-font-family, and --code-font-familyfor typography --text-color-primary, --color-accent, and --surface-backgroundfor color and contrast --content-spacingand --content-widthfor layout rhythm --border-radius-defaultand --border-color-defaultfor component framing
tokens-primitive.csstokens-semantic.css
Token Types
Targets
Architecture
Base Theme Entry Point ( base/index.css)
base/index.cssToken Layers and Root Styles
tokens-primitive.css- Primitive design tokens (raw colors, spacing, font stacks) tokens-semantic.css- Semantic design tokens with dark/print variants root.css- Base document styles and global resets browsers.css- Browser normalization and cross-browser adjustments pages.css- Paged media ( @page) tokens and margin box rules
Typography Modules
links.css- Link reset, styling, focus states, and accessibility headings.css- Complete heading system with reset, h1-h6 styles, and mobile adjustments paragraphs.css- Paragraph styling including lead paragraphs and mobile optimizations lists.css- List reset, ul/ol/li styling, nesting, and mobile adjustments
Content Modules
code.css- Inline and block code styling with mobile adjustments tables.css- Table styling, captions, notes, and print variants datatables.css- Datatable styling for typed column tables figures.css- Figure and figcaption styling for Stencila figure components images.css- Image object styling for inline and block images quotes.css- Blockquote styling with mobile adjustments math.css- Mathematical content font styling breaks.css- Thematic break (horizontal rule) styling
Stencila Components
admonitions.css- Stencila admonition component styling citations.css- Citation and citation group styling diagrams.css- Diagram theming (applied via JavaScript integration) plots.css- Plot theming tokens for supported plotting libraries references.css- Bibliographic reference styling
Print Support
pages.css@media print
Base Theme Loading
base.css
In HTML output, base.cssis injected as a separate <link>tag before your theme stylesheet. For variable computation, base variables are parsed and merged before theme-specific variables, so all base tokens are always available to your theme.
@import url("./base.css")theme.css:root
:root {
--text-font-family: "Your Font", serif;
}@import:root
@import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');
:root {
--heading-font-family: "Inter", sans-serif;
}stencilatuftelatexbase.css