Skip to main content
This article covers styling your plugin with theme tokens, the CSS variables Cortex passes to plugins so they match the look and feel of the rest of the product. Tokens reflect the current user’s theme, including custom brand colors and light or dark mode.

Setting up theming in your plugin

Plugins created from the plugin template are already set up for theming. Skip to Using theme tokens.
To set up theming in a plugin:
  1. Install @cortexapps/plugin-core and @cortexapps/react-plugin-ui.
  2. Import @cortexapps/react-plugin-ui/index.css in your entry file.
  3. Call CortexApi.pluginInit() before rendering your app, so the theme arrives before your plugin renders.
  4. Wrap your app in <PluginProvider> from @cortexapps/plugin-core/components. See the template’s App.tsx for an example.
If the tokens aren’t applied, make sure @cortexapps/plugin-core is up to date, CortexApi.pluginInit() is called before your app renders and your app is wrapped in <PluginProvider>.

Theme token reference

The following tokens are available to your plugin.

Using theme tokens

Reference a token anywhere you would use a color value. For example, in CSS:
If you use Tailwind, reference tokens with arbitrary values:

Adding fallback values

Add a fallback value so your plugin still renders correctly if the theme hasn’t loaded yet:
Note: Fallbacks are fixed values, so they don’t follow brand colors or dark mode.

Supporting light and dark mode

You don’t need to define separate colors for light and dark mode. Token values change with the user’s setting, so anything styled with tokens switches automatically. <PluginProvider> also adds a light or dark class to the <html> element. Use this class for anything the tokens don’t cover, such as swapping an image:

Using the component library

The quickest way to match Cortex is to build your plugin with @cortexapps/react-plugin-ui. Its components already use the theme tokens, so they follow the user’s theme with no extra styling. The library includes the following components:
  • Badge
  • Breadcrumb
  • Button
  • Card
  • Checkbox
  • Dialog
  • Input
  • Label
  • Loader
  • Progress
  • Select
  • Tabs
  • Typeahead

Component examples

Import components from @cortexapps/react-plugin-ui. For example, a card with a badge and a button:
Tabs:
An input with a label:
Last modified on October 9, 2026