Getting Started
A step-by-step guide to get started with Cerberus.What is Cerberus?
Cerberus is a UI-like flexible design system that is built on top of Panda CSS. It uses two foundational packages:
- Panda Preset
- React
Panda Preset
The Cerberus Panda Preset is a set of tokens, recipes, conditions, utilities, patterns, and more that are built on top of Panda CSS. It provides a consistent look and feel for your application and makes it easy to get started with Panda CSS.
Cerberus React
The Cerberus React is a set of pre-configured components that are built on top of the Panda CSS preset. It provides a set of components that can be categorized into 3 groups:
- Abstractions - Abstracted component APIs of the primitives
- Primitives - Low level component APIs for fine-grained control
- Parts - Object oriented components that are used to build the abstractions
Setup Guide
Step 1 - Setup Panda CSS
Before you can use the Cerberus, you need to have Panda CSS installed and setup in your project.
Head over to the Panda CSS installation guide to get started.
Step 2 - Setup the Cerberus Preset
In order to use the Cerberus React, you need to install the Cerberus preset package.
npx jsr add @cerberus/panda-preset
pnpm dlx jsr add @cerberus/panda-preset
npx jsr add @cerberus/panda-preset
Next, update your PandaCSS config to utilize the Cerberus helpers:
1import {2 createCerberusConfig,3 createCerberusPreset,4} from '@cerberus/panda-preset'5
6export default createCerberusConfig({7 presets: [createCerberusPreset()],8
9 include: ['./app/**/*.{ts,tsx}'],10 exclude: [],11})
The createCerberusConfig
function adds the recommended Cerberus settings and any additional settings you pass into it.
The createCerberusPreset
function does the same except on the preset level.
Step 3 - Update your root layout to trigger Cerberus
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.
1function RootLayout({ children }) {2 return (3 <html lang="en" data-panda-theme="cerberus" data-color-mode="light">4 <body>{children}</body>5 </html>6 )7}
This is a good point to run your panda codegen
command to generate the Cerberus related additions.
Path Aliases
Cerberus React assumes you have your baseUrl
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.
1{2 "compilerOptions": {3 "baseUrl": ".",4 "paths": {5 "@/*": ["./*"]6 }7 }8}
Step 4 - Setup Cerberus React
Cerberus React is icon agnostic which means you should install the Icon library of choice before installing the Cerberus React package.
npm install @cerberus/react@npm:@cerberus-design/react
pnpm add @cerberus/react@npm:@cerberus-design/react
yarn add @cerberus/react@npm:@cerberus-design/react
Step 5 - Registering Your Icons
Because Cerberus React is icon agnostic, you need to register the library you prefer. This will map certain icons to the Cerberus components that depend on them.
If you do not have an icon preference, we recommend using the Carbon Icons library.
npm install @carbon/icons-react
pnpm add @carbon/icons-react
yarn add @carbon/icons-react
Create your Cerberus Config
In Next, you will need to create a new file to wrap your application with the CerberusProvider
where you will keep your global settings.
We will name this abstraction CerberusConfig
since it will own the Cerberus configuration.
1'use client'2
3import {4 CerberusProvider,5 defineIcons,6 makeSystemConfig,7} from '@cerberus/react'8import {9 Calendar,10 Checkmark,11 CheckmarkOutline,12 ChevronDown,13 ChevronLeft,14 ChevronRight,15 Close,16 CloudUpload,17 Information,18 Restart,19 TrashCan,20 UserFilled,21 Warning,22 WarningAlt,23 WarningFilled,24} from '@carbon/icons-react'25import type { PropsWithChildren } from 'react'26
27/**28 * This module provides a Cerberus configuration component which must to be used29 * in a client abstraction because of React 19 rules around data passing into30 * props.31 */32
33const icons = defineIcons({34 accordionIndicator: ChevronDown,35 avatar: UserFilled,36 calendar: Calendar,37 calendarPrev: ChevronLeft,38 calendarNext: ChevronRight,39 close: Close,40 confirmModal: Information,41 delete: TrashCan,42 promptModal: Information,43 waitingFileUploader: CloudUpload,44 infoNotification: Information,45 successNotification: CheckmarkOutline,46 warningNotification: WarningAlt,47 dangerNotification: WarningFilled,48 invalid: WarningFilled,49 invalidAlt: Warning,50 redo: Restart,51 selectArrow: ChevronDown,52 selectChecked: Checkmark,53 toggleChecked: Checkmark,54})55
56const config = makeSystemConfig({57 icons,58})59
60export default function CerberusConfig(props: PropsWithChildren<{}>) {61 return <CerberusProvider config={config}>{props.children}</CerberusProvider>62}
Then wrap your application with the CerberusConfig
component:
1import { Poppins, Recursive } from 'next/font/google'2import { type PropsWithChildren } from 'react'3import { css, cx } from 'styled-system/css'4import CerberusConfig from '@/context/cerberus-config'5
6import './globals.css'7
8const poppins = Poppins({9 display: 'swap',10 subsets: ['latin'],11 weight: ['400', '600', '700'],12 variable: '--font-poppins',13})14const recursive = Recursive({15 display: 'swap',16 subsets: ['latin'],17 weight: ['400'],18 variable: '--font-recursive',19})20
21interface RootProps {}22
23export default function RootLayout(props: PropsWithChildren<RootProps>) {24 return (25 <html26 className={cx(poppins.variable, recursive.variable)}27 data-panda-theme="cerberus"28 data-color-mode="light"29 lang="en"30 >31 <body>32 <CerberusConfig>33 {props.children}34 </CerberusConfig>35 </body>36 </html>37 )38}
Tip: Add a Cerberus script
To help make maintaining a breeze, add this new script to your package.json
to use when you need to upgrade Cerberus:
1"scripts": {2 "up:cerberus": "pnpm up @cerberus/react@latest && pnpm dlx jsr add @cerberus/panda-preset && pnpm up @pandacss/dev@latest"3}
Now you can update Cerberus and PandaCSS with a single command:
npm run up:cerberus
pnpm run up:cerberus
yarn run up:cerberus
FAQ
Why does the package path for react look weird?
The Cerberus packages are published under the @cerberus-design
organization in NPM (due to the name cerberus
being taken). However, in JSR, we use the @cerberus
organization. We eventually plan on fully migrating to JSR when there is better support for the features we need.
The version paths are simply creating an alias to the @cerberus-design
organization so that you can have consistent package naming across your project.
Everything should use the @cerberus
organization in your code.
Why do I need to have a specific baseUrl
in our tsconfig.json?
In order for our React components to know where to find the styled-system APIs, it needs to know where to look. By setting the baseUrl
to the root of your project, we can use the styled-system
import path without needing to know the exact location of the file.
On this page