Head over to the Panda CSS installation guide to get started.
Note
We recommend using the App Router for your Next.js project. The Pages Router (deprecated) has some known issues regarding atomic css generation.
Now that Panda is installed, you need to install the Cerberus preset package. We publish as many packages to JSR as possible to ensure a better experience for developers.
Next, update your PandaCSS config to utilize the Cerberus helpers:
The createCerberusConfig function adds the required Cerberus config settings
to PandaCSS along with any additional settings you pass into it.
The createCerberusPreset function does the same except on the preset level.
The core preset comes with the base "cerberus" theme and PandaCSS presets built in:
Note
If you are using the panda-preset there is no need to install the additional PanaCSS base presets. The core preset will set everything up on your behalf.
The Cerberus core preset includes a set of font helpers. In order to utilize them, your project needs to have your preferred fonts assigned to the following CSS variables:
--font-display: Any display heading text-style--font-sans: Any other text style--font-mono: Any monospace text styleIf using NextJS fonts, you can simply import and assign these with the fonts package:
Because Cerberus provides multiple themes and modes out of the box, you need to initialize your root layout to trigger the default options you want to use.
To connect the Cerberus theme, add the required data attributes to your root html tag.
Important: This is a good point to run the panda codegen command to
generate the Cerberus related additions.
Once this has been run, you can start using Cerberus styles and themes in your project. If you are interested in using the React library, continue
To add the React library to your project, continue in the guide.
Note
The React library requires the Panda-Preset to be setup in order to use.
Cerberus React assumes the baseUrl is setup to the root location in your tsconfig.json file.
If you do not, or use a different location, you should include a path alias for
the styled-system/* location. Not doing so will result in build errors.
Note
If using Deno, simply setup your import map to include the styled-system/\* alias.
Now that your base path is setup, you can install Cerberus React.
Note
In the snippet above, we are simply creating an alias path for NPM to use of the name we prefer. For Deno users, we recommend adding an alias to your import map for consistency.
Add the build config to the include array so Panda can generate the styles.
In order for components to have access to icons, you must wrap your application with the CerberusProvider context.
At this point, you are ready to start using Cerberus React.
React comes built in with the Carbon Icons set. However, if you prefer a different icon library, you can register it with Cerberus Context Provider.
If you want to support multiple themes, you can use the presetAcheronTheme and getThemeName helpers to configure your theme.
To help make maintaining a breeze, add these scripts to your package.json to
use when you need to upgrade Cerberus:
Now you can update Cerberus and PandaCSS with a single command:
npx jsr add @cerberus/panda-presetpnpm add jsr:@cerberus/panda-presetdeno add jsr:@cerberus/panda-presetbunx jsr add @cerberus/panda-presetnpm install @cerberus/react@npm:@cerberus-design/reactpnpm add @cerberus/react@npm:@cerberus-design/reactdeno add npm:@cerberus-design/reactbun add @cerberus/react@npm:@cerberus-design/reactnpm run up:cerberuspnpm run up:cerberusdeno run npm:up:cerberusbun run up:cerberus