Theming and Tokens
React Core components are styled with design tokens exposed as CSS variables (--ds-*). Theming is controlled by your app, not by individual components.
How it works
- Importing
@cfa/react-core/index.cssloads the token variables for every theme. You do not need to install or import@cfa/design-tokens-coreseparately to use them. - The default theme is applied on
:root, so no attribute is needed. - To use another theme, set a
data-themeattribute on an element. The base themes areexperimental-red(default) andexperimental-navy.cfa-redandcfa-navyare legacy themes; prefer the base themes. - Components do not accept a theme prop and do not set
data-themethemselves. They read the variables from the nearest themed ancestor.
<html data-theme="experimental-navy"> ...</html>Recommendations
- Set the theme once at the app level, on
<html>(preferred) or an element that contains everything you render. - Overlays such as
Modal,Drawer, andPopoverrender outside your component tree, so a theme set on a nested wrapper may not reach them. Putdata-themeon<html>so overlays inherit it. - Reference tokens through the
--ds-*variables in your own styles instead of hard-coded colors, sizes, or radii. Use thesearch_tokensMCP tool to look up names. - Do not rely on token values being the same across themes. Always use the variable.