### Install Data Grid with Deno
Source: https://cerberus.digitalu.design/docs/data-grid/overview
Install the Data Grid package using Deno. The package is aliased to the Cerberus design package.
```bash
deno add npm:@cerberus/data-grid@npm:@cerberus-design/data-grid
```
--------------------------------
### Install Data Grid with Bun
Source: https://cerberus.digitalu.design/docs/data-grid/overview
Install the Data Grid package using Bun. The package is aliased to the Cerberus design package.
```bash
bun add @cerberus/data-grid@npm:@cerberus-design/data-grid
```
--------------------------------
### useQuery Usage Examples
Source: https://cerberus.digitalu.design/docs/signals/use-query
Examples of using useQuery in React components.
```javascript
import { useQuery } from '@cerberus/signals'
```
```jsx
{
user
}
```
```tsx
'use client'
import { useQuery } from '@cerberus/react/signals'
import { queryUser } from './queries'
import { type User } from './db'
interface Props {
id: string
initialData: User
}
export function UserProfile(props: Props) {
// 1. Cerberus sees `initialData`, instantly seeds the $O(1) Map,
// and mounts the component with zero loading spinners or network waterfalls.
const user = useQuery(queryUser(props.id), { initialData: props.initialData })
if (!user) return null
return
{user.name}
}
```
--------------------------------
### Nesting Signals Example
Source: https://cerberus.digitalu.design/docs/signals/reactivity
Shows a nested signal structure example, illustrating how signals can be nested.
```json
{
"data": {
"count": 0,
"unique": 0
},
"finalCount": 0
}
```
--------------------------------
### Install Vitest and Testing Library dependencies with Deno
Source: https://cerberus.digitalu.design/docs/components/testing
Install Vitest and Testing Library packages as dev dependencies using Deno. Required before writing tests.
```bash
deno add npm:--save-dev
```
--------------------------------
### Using Actions: Toggle Pinned Example
Source: https://cerberus.digitalu.design/docs/data-grid/context
Shows how to use the Data Grid store's togglePinned action directly from the store. The example uses useDataGridContext to get the store and a Button to trigger the action.
```tsx
'use client'
import { useDataGridContext } from '@cerberus/react/data-grid'
import { Button } from '@cerberus/react/react'
import { MouseEvent } from 'react'
import { type Employee } from '../api'
export function ActionDemo() {
const store = useDataGridContext()
function handleUpdateData(e: MouseEvent) {
store.togglePinned(e.currentTarget.value, 'left')
}
return (
)
}
```
--------------------------------
### Install Vitest and Testing Library dependencies with Bun
Source: https://cerberus.digitalu.design/docs/components/testing
Install Vitest, jsdom, and Testing Library packages as dev dependencies using Bun. Required before writing tests.
```bash
bun add --save-dev vitest jsdom @testing-library/dom @testing-library/jest-dom @testing-library/react @testing-library/user-event
```
--------------------------------
### Basic CerberusProvider usage
Source: https://cerberus.digitalu.design/docs/components/cerberus-context
Wrap your application with CerberusProvider to provide the context to child components. This example shows a minimal setup without additional configuration.
```typescript
'use client'
import { CerberusProvider } from '@cerberus-design/react'
import { type PropsWithChildren } from 'react'
export function CerberusConfig(props: PropsWithChildren) {
return {props.children}
}
```
--------------------------------
### Install @cerberus/react with deno
Source: https://cerberus.digitalu.design/docs/components/overview
Install the Cerberus Components Library using deno. This command adds the package directly without the alias.
```bash
deno add npm:@cerberus-design/react
```
--------------------------------
### Install Data Grid with npm
Source: https://cerberus.digitalu.design/docs/data-grid/overview
Install the Data Grid package using npm. The package is aliased to the Cerberus design package.
```bash
npm install @cerberus/data-grid@npm:@cerberus-design/data-grid
```
--------------------------------
### Install Data Grid with pnpm
Source: https://cerberus.digitalu.design/docs/data-grid/overview
Install the Data Grid package using pnpm. The package is aliased to the Cerberus design package.
```bash
pnpm add @cerberus/data-grid@npm:@cerberus-design/data-grid
```
--------------------------------
### Install Vitest and Testing Library dependencies with npm
Source: https://cerberus.digitalu.design/docs/components/testing
Install Vitest, jsdom, and Testing Library packages as dev dependencies using npm. Required before writing tests.
```bash
npm install --save-dev vitest jsdom @testing-library/dom @testing-library/jest-dom @testing-library/react @testing-library/user-event
```
--------------------------------
### Install @cerberus/signals with npm, pnpm, deno, or bun
Source: https://cerberus.digitalu.design/docs/signals/overview
Install the @cerberus/signals package using your preferred package manager. The package is published under the @cerberus-design scope and requires React to be installed.
```bash
npm install @cerberus/signals@npm:@cerberus-design/signals
```
```bash
pnpm add @cerberus/signals@npm:@cerberus-design/signals
```
```bash
deno add npm:@cerberus/signals@npm:@cerberus-design/signals
```
```bash
bun add @cerberus/signals@npm:@cerberus-design/signals
```
--------------------------------
### Basic Presence example
Source: https://cerberus.digitalu.design/docs/components/presence
By default, the child component starts hidden and remains hidden after the present state is toggled off. This example uses useSignal to manage the present state and a button to toggle it.
```tsx
'use client'
import { Presence } from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
export const Basic = () => {
const [present, setPresent] = useSignal(false)
return (
<>
Hidden and Hidden
>
)
}
```
--------------------------------
### Install Vitest and Testing Library dependencies with pnpm
Source: https://cerberus.digitalu.design/docs/components/testing
Install Vitest, jsdom, and Testing Library packages as dev dependencies using pnpm. Required before writing tests.
```bash
pnpm add --save-dev vitest jsdom @testing-library/dom @testing-library/jest-dom @testing-library/react @testing-library/user-event
```
--------------------------------
### Configuration Options Example
Source: https://cerberus.digitalu.design/docs/components/json-tree-view
Shows how to configure the JSON tree view with options like defaultExpandedDepth, quotesOnKeys, showNonenumerable, maxPreviewItems, collapseStringsAfterLength, and groupArraysAfterLength.
```jsx
} />
```
--------------------------------
### Install @cerberus/react with bun alias
Source: https://cerberus.digitalu.design/docs/components/overview
Install the Cerberus Components Library using bun, creating an alias @cerberus/react to @cerberus-design/react. This keeps imports consistent and avoids versioning issues.
```bash
bun add @cerberus/react@npm:@cerberus-design/react
```
--------------------------------
### Install Cerberus Panda Preset with Bun
Source: https://cerberus.digitalu.design/docs/get-started/installation
Use this command to add the @cerberus/panda-preset package to your project using Bun.
```bash
bunx jsr add @cerberus/panda-preset
```
--------------------------------
### Access environment context with useEnvironmentContext
Source: https://cerberus.digitalu.design/docs/components/environment
Use the useEnvironmentContext hook to access the RootNode, Document, and Window. The example shows how to get the root node and display it as JSON.
```jsx
import { useEnvironmentContext } from '@cerberus/react'
export const Usage = () => {
const { getRootNode } = useEnvironmentContext()
return
{JSON.stringify(getRootNode(), null, 2)}
}
```
--------------------------------
### Example mutation data
Source: https://cerberus.digitalu.design/docs/signals/use-mutation
Example of the data returned by a mutation, containing an id and name.
```json
{
"id": "f774c898-1702-4bdf-9a2c-484042f763db",
"name": "Cerby the Dawg"
}
```
--------------------------------
### Use context7 in Cursor prompt
Source: https://cerberus.digitalu.design/docs/get-started/context-7
Add `use context7` to your prompt in Cursor to have Context7 MCP pull up-to-date, version-specific documentation and code examples directly into your prompt.
```text
Create a Next.js middleware that checks for a valid JWT in cookies and redirects unauthenticated users to `/login`. use context7
```
--------------------------------
### Set up test environment in setup-test.ts
Source: https://cerberus.digitalu.design/docs/components/testing
Create setup-test.ts to configure the testing environment and mock unimplemented APIs. This common example for Cerberus projects mocks ResizeObserver, IntersectionObserver, scroll methods, requestAnimationFrame, URL object, navigator clipboard, and overrides globalThis.
```typescript
import '@testing-library/jest-dom/vitest'
import { JSDOM } from 'jsdom'
import ResizeObserver from 'resize-observer-polyfill'
import { vi } from 'vitest'
import 'vitest-axe/extend-expect'
const { window } = new JSDOM()
// ResizeObserver mock
vi.stubGlobal('ResizeObserver', ResizeObserver)
window['ResizeObserver'] = ResizeObserver
// IntersectionObserver mock
const IntersectionObserverMock = vi.fn(() => ({
disconnect: vi.fn(),
observe: vi.fn(),
takeRecords: vi.fn(),
unobserve: vi.fn(),
}))
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock)
window['IntersectionObserver'] = IntersectionObserverMock
// Scroll Methods mock
window.Element.prototype.scrollTo = () => {}
window.Element.prototype.scrollIntoView = () => {}
// requestAnimationFrame mock
window.requestAnimationFrame = (cb) => setTimeout(cb, 1000 / 60)
// URL object mock
window.URL.createObjectURL = () => 'https://i.pravatar.cc/300'
window.URL.revokeObjectURL = () => {}
// navigator mock
Object.defineProperty(window, 'navigator', {
value: {
clipboard: {
writeText: vi.fn(),
},
},
})
// Override globalThis
Object.assign(global, { window, document: window.document })
```
--------------------------------
### Install @cerberus/react with pnpm alias
Source: https://cerberus.digitalu.design/docs/components/overview
Install the Cerberus Components Library using pnpm, creating an alias @cerberus/react to @cerberus-design/react. This keeps imports consistent and avoids versioning issues.
```bash
pnpm add @cerberus/react@npm:@cerberus-design/react
```
--------------------------------
### Install @cerberus/react with npm alias
Source: https://cerberus.digitalu.design/docs/components/overview
Install the Cerberus Components Library using npm, creating an alias @cerberus/react to @cerberus-design/react. This keeps imports consistent and avoids versioning issues.
```bash
npm install @cerberus/react@npm:@cerberus-design/react
```
--------------------------------
### Batch Increment Example
Source: https://cerberus.digitalu.design/docs/signals/batch
Updates two signals at once within a batch block, both referencing the same signal value. The example shows a count and an isEven signal.
```javascript
batch(() => {
// update signals here
})
```
--------------------------------
### Synchronous Reactivity Example
Source: https://cerberus.digitalu.design/docs/signals/reactivity
Demonstrates synchronous reactivity where the double signal is updated immediately after count changes.
```javascript
import { createEffect, createSignal } from '@cerberus/react/signals'
const [count, _setCount] = createSignal(0)
const [_double, setDouble] = createSignal(0)
createEffect(() => {
setDouble(count() * 2)
})
```
--------------------------------
### Rotate Example
Source: https://cerberus.digitalu.design/docs/components/swap
Rotate the indicators in and out with a spin transition.
```tsx
import { Swap } from '@cerberus/react'
import { MoonIcon, SunIcon } from 'lucide-react'
import { useState } from 'react'
import styles from 'styles/swap.module.css'
export const Rotate = () => {
const [swapped, setSwapped] = useState(false)
return (
)
}
```
--------------------------------
### Fade Example
Source: https://cerberus.digitalu.design/docs/components/swap
Swap between two icons with a fade animation. Set the swap prop to toggle between the on and off indicators.
```tsx
'use client'
import { Button, Swap } from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
import { CheckIcon, XIcon } from 'lucide-react'
import styles from 'styles/swap.module.css'
export const Fade = () => {
const [swapped, setSwapped] = useSignal(false)
return (
)
}
```
--------------------------------
### Context provider setup - CerberusAppProvider
Source: https://cerberus.digitalu.design/docs/components/overview
Provides a recommended pattern for wrapping your application with the CerberusProvider. The component uses makeSystemConfig and passes it to CerberusProvider to make context available to all components.
```tsx
'use client'
import { CerberusProvider, makeSystemConfig } from '@cerberus/react'
import { PropsWithChildren } from 'react'
const config = makeSystemConfig()
export function CerberusAppProvider(props: PropsWithChildren) {
return {props.children}
}
```
--------------------------------
### Create a Cerberus primitive with withRecipe
Source: https://cerberus.digitalu.design/docs/styling/cerberus-factory
Apply a specific recipe using 'withRecipe' for component styling. The example creates a button with the 'button' recipe from 'styled-system/recipes', and the component uses 'css' for styles. For instance, the recipe is imported from 'styled-system/recipes'.
```javascript
import { cerberus, createCerberusPrimitive } from '@cerberus/react'
import { button } from 'styled-system/recipes'
const { withRecipe } = createCerberusPrimitive(button)
const Button = withRecipe('button')
function Example() {
return
}
```
--------------------------------
### Background Image with bgImage and gradients
Source: https://cerberus.digitalu.design/docs/styling/background
Use `bgImage` or `backgroundImage` to set the background image. The example shows URL, radial-gradient, linear-gradient, and a token reference in a gradient.
```jsx
// with token reference
```
--------------------------------
### Install Cerberus Panda Preset with Deno
Source: https://cerberus.digitalu.design/docs/get-started/installation
Use this command to add the @cerberus/panda-preset package to your project using Deno. Deno has first-class support for JSR packages.
```bash
deno add jsr:@cerberus/panda-preset
```
--------------------------------
### Install Cerberus Panda Preset with npx
Source: https://cerberus.digitalu.design/docs/get-started/installation
Use this command to add the @cerberus/panda-preset package to your project using npx (NPM). This is the recommended way when using NPM.
```bash
npx jsr add @cerberus/panda-preset
```
--------------------------------
### Background Size with bgSize
Source: https://cerberus.digitalu.design/docs/styling/background
Use `bgSize` or `backgroundSize` to control the size of a background image. The example sets it to `cover`.
```jsx
```
--------------------------------
### Apply opacity to color token with bgColor
Source: https://cerberus.digitalu.design/docs/styling/color-opacity-modifier
Use the `color-mix` shortcut with the syntax `{color}/{opacity}` on a color related style property. The example sets the background color to `danger.bg.initial` at 40% opacity and the text color to `danger.text.initial`.
```jsx
Hello World
```
--------------------------------
### Flip Example
Source: https://cerberus.digitalu.design/docs/components/swap
Add a 3D flip effect by setting perspective on the root and using rotateY keyframes on the indicators.
```tsx
import { Button, Swap } from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
import { PauseIcon, PlayIcon } from 'lucide-react'
import styles from 'styles/swap.module.css'
export const Flip = () => {
const [swapped, setSwapped] = useState(false)
return (
)
}
```
--------------------------------
### Scale Example
Source: https://cerberus.digitalu.design/docs/components/swap
Scale the indicators up and down for a pop-in effect.
```tsx
import { Swap } from '@cerberus/react'
import { Volume2Icon, VolumeXIcon } from 'lucide-react'
import { useState } from 'react'
import styles from 'styles/swap.module.css'
export const Scale = () => {
const [swapped, setSwapped] = useState(false)
return (
)
}
```
--------------------------------
### File Transformations with transformFiles and image-conversion
Source: https://cerberus.digitalu.design/docs/components/file-uploader
Use the transformFiles prop to process files before they are added to the accepted list. This example compresses image files to ~200KB using compressAccurately from image-conversion, returning non-image files unchanged. The FileUploader is configured with accept="image/*" and maxFiles={5}.
```tsx
import { FileUploader } from '@cerberus/react/file-upload'
import { compressAccurately } from 'image-conversion'
function FileTransformationsDemo() {
const transformFiles = async (files: File[]) => {
return Promise.all(
files.map(async (file) => {
if (file.type.startsWith('image/')) {
try {
// Compress image to ~200KB
const blob = await compressAccurately(file, 200)
return new File([blob], file.name, { type: blob.type })
} catch (error) {
console.error('Compression failed for:', file.name, error)
return file
}
}
return file // Return non-image files as-is
}),
)
}
return
}
```
--------------------------------
### transitionDelay prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `transitionDelay` prop to control the delay of a transition. The example sets it to `fast`.
```jsx
Hover me
```
--------------------------------
### Create system config with makeSystemConfig
Source: https://cerberus.digitalu.design/docs/theming/overview
Pass a config object to makeSystemConfig to create low-level options for components. The example shows defining icons and passing them to the config.
```typescript
const icons = defineIcons({...})
const config = makeSystemConfig({
icons,
})
```
--------------------------------
### Configure globalCss
Source: https://cerberus.digitalu.design/docs/theming/overview
Applies global styles to the root element. These styles are not atomized. The example zeroes out margin and padding on 'html, body'.
```javascript
export default createCerberusConfig({
globalCss: {
'html, body': {
margin: 0,
padding: 0,
},
},
})
```
--------------------------------
### Array syntax for responsive styles
Source: https://cerberus.digitalu.design/docs/styling/responsive-design
Pass an array of values for each breakpoint. This example sets medium at the base breakpoint and bold at the xl breakpoint, leaving md and lg as undefined.
```tsx
Text
```
--------------------------------
### Set up CerberusProvider with makeSystemConfig and defineIcons
Source: https://cerberus.digitalu.design/docs/theming/overview
This snippet shows the complete setup for the Cerberus theming system. It imports the necessary components and icons, defines the icon mappings using defineIcons, creates the system config with makeSystemConfig, and wraps the application in a CerberusProvider. Use this as the root layout for your app to enable theming.
```tsx
'use client'
import { CerberusProvider, defineIcons, makeSystemConfig } from '@cerberus-design/react'
import {
Calendar,
Checkmark,
CheckmarkOutline,
ChevronDown,
ChevronLeft,
ChevronRight,
Close,
CloudUpload,
Information,
Restart,
TrashCan,
UserFilled,
Warning,
WarningAlt,
WarningFilled,
} from '@carbon/icons-react'
import type { PropsWithChildren } from 'react'
const icons = defineIcons({
accordionIndicator: ChevronDown,
avatar: UserFilled,
calendar: Calendar,
calendarPrev: ChevronLeft,
calendarNext: ChevronRight,
close: Close,
confirmModal: Information,
delete: TrashCan,
promptModal: Information,
waitingFileUploader: CloudUpload,
infoNotification: Information,
successNotification: CheckmarkOutline,
warningNotification: WarningAlt,
dangerNotification: WarningFilled,
invalid: WarningFilled,
invalidAlt: Warning,
redo: Restart,
selectArrow: ChevronDown,
selectChecked: Checkmark,
toggleChecked: Checkmark,
})
const config = makeSystemConfig({
icons,
})
export default function CerberusConfig(props: PropsWithChildren<{}>) {
return {props.children}
}
```
--------------------------------
### Setup EnvironmentProvider with iframe
Source: https://cerberus.digitalu.design/docs/components/environment
Wrap your app in EnvironmentProvider inside a Frame to provide environment context for iframe, Shadow DOM, or Electron. The provider automatically detects the environment.
```jsx
import { EnvironmentProvider } from '@cerberus/react'
import Frame from 'react-frame-component'
export const App = () => {
return (
{/* Your App */}
)
}
```
--------------------------------
### Combining Lazy Mount and Unmount on Exit example
Source: https://cerberus.digitalu.design/docs/components/presence
Both lazyMount and unmountOnExit can be combined so the component is mounted only when present and unmounted when no longer present.
```tsx
'use client'
import { Presence } from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
export const LazyMountAndUnmountOnExit = () => {
const [present, setPresent] = useSignal(false)
return (
<>
Lazy Mount and Unmounted on Exit
>
)
}
```
--------------------------------
### Run prepare with deno
Source: https://cerberus.digitalu.design/docs/styling/layer-styles
Run the prepare script using deno.
```bash
deno run npm:prepare
```
--------------------------------
### Object syntax for responsive styles
Source: https://cerberus.digitalu.design/docs/styling/responsive-design
Use the object syntax to apply responsive styles directly to a style property. This example shows the concise syntax with `base` and `lg` keys.
```tsx
Text
```
--------------------------------
### Create a themable outline button with virtual colors
Source: https://cerberus.digitalu.design/docs/styling/virtual-color
Use the `css` prop to define a virtual color palette for a Button. The example sets `colorPalette` to 'action' and uses `colorPalette.border.initial`, `colorPalette.border.100`, and `colorPalette.border.focus` for border colors, and `colorPalette.text.initial` for text color.
```tsx
```
--------------------------------
### Define compound variants with defineSlotRecipe
Source: https://cerberus.digitalu.design/docs/theming/slot-recipes
Use the `compoundVariants` property to apply styles when a combination of variants is active. In this example, when `size` is 'sm' and `visual` is 'outline', the control gets a border width of 1px and the label gets a green color.
```typescript
import { defineSlotRecipe } from '@pandacss/dev'
export const checkboxRecipe = defineSlotRecipe({
slots: ['root', 'control', 'label'],
base: {},
variants: {
size: {
sm: {},
md: {},
},
visual: {
contained: {},
outline: {},
},
},
compoundVariants: [
{
size: 'sm',
visual: 'outline',
css: {
control: { borderWidth: '1px' },
label: { color: 'green.500' },
},
},
],
})
```
--------------------------------
### Run prepare with bun
Source: https://cerberus.digitalu.design/docs/styling/layer-styles
Run the prepare script using bun.
```bash
bun run prepare
```
--------------------------------
### Import Menu components from '@cerberus/react'
Source: https://cerberus.digitalu.design/docs/components/menu
Imports the Menu and its related components from the @cerberus/react package. This is the required setup before using the menu primitives.
```tsx
import {
Menu,
MenuTrigger,
MenuContent,
MenuItem,
MenuItemGroup,
MenuGroupLabel,
MenuSeparator,
} from '@cerberus/react'
```
--------------------------------
### Run prepare with npm
Source: https://cerberus.digitalu.design/docs/styling/layer-styles
Run the prepare script using npm.
```bash
npm run prepare
```
--------------------------------
### Use the br utility in a component
Source: https://cerberus.digitalu.design/docs/styling/utilities
After regenerating the styled-system, the new utility can be used as a prop on components. This example shows a Button with the 'br' prop set to 'sm'.
```TypeScript
import { Button } from '@cerberus/react'
export const MyButton = () => {
return
}
```
--------------------------------
### Caveat: compoundVariants with responsive values
Source: https://cerberus.digitalu.design/docs/theming/recipes
This example will not work because compoundVariants does not support responsive values. The size prop uses a responsive object, which is not allowed.
```jsx
```
--------------------------------
### Dynamic Imports with Suspense
Source: https://cerberus.digitalu.design/docs/components/dialog
Example of using lazyMount with lazy or Next.js dynamic imports. Wrap the imported component in Suspense to handle loading states.
```tsx
import { Dialog, DialogProvider, DialogTrigger } from '@cerberus/react/react'
import dynamic from 'next/dynamic'
import { Suspense } from 'react'
const HeavyComponent = dynamic(() => import('./heavy'))
export function DynamicDemo() {
return (
Open
)
}
```
--------------------------------
### Create a Cerberus primitive with withSlotRecipe
Source: https://cerberus.digitalu.design/docs/styling/cerberus-factory
Use 'withSlotRecipe' to create multi-slot components, each slot with its own recipe styles. This example creates a field with root, label, and input slots, each styled via the 'field' slot recipe.
```javascript
import { cerberus, createCerberusPrimitive } from '@cerberus/react'
import { field } from 'styled-system/recipes/slots'
const { withSlotRecipe } = createCerberusPrimitive(field)
const Field = withSlotRecipe('div', 'root')
const FieldLabel = withSlotRecipe('label', 'label')
const FieldInput = withSlotRecipe('input', 'input')
function Example() {
return (
Label
)
}
```
--------------------------------
### Define columns with accessor, accessorFn, and display
Source: https://cerberus.digitalu.design/docs/data-grid/quickstart
Define the columns array using the columnHelper. It includes examples of accessor, accessorFn, and display columns with features like pinning, sorting, and filtering.
```tsx
'use client'
import { Edit } from '@carbon/icons-react'
import { Format, IconButton, Tag, TagProps, Text } from '@cerberus/react/react'
import { HStack, VStack } from 'styled-system/jsx'
import { columnHelper } from './helper.demo'
export const columns = [
// A. "ID" Column that can be pinned and sorted
columnHelper.accessor('id', {
header: 'ID',
width: 80,
features: {
pinning: {
defaultPosition: 'left',
},
sort: true,
},
cell: ({ value }) => #{value},
}),
// B. Derived Accessor (Function)
// We combine First + Last name for sorting/filtering, but render custom UI
columnHelper.accessorFn((row) => `${row.firstName} ${row.lastName}`, {
id: 'fullName',
header: 'Employee',
width: 250,
features: {
sort: true,
filter: true,
},
cell: ({ row, value }) => (
{value}
{row.email}
),
}),
// C. Deep Accessor (Nested Object) using a plain text string for the cell
columnHelper.accessorFn((row) => row.department.name, {
id: 'department',
header: 'Department',
features: { sort: true },
}),
// D. Formatting (Numeric Sort, String Display)
columnHelper.accessor('salary', {
header: 'Salary',
minWidth: 135,
features: { sort: true }, // ✅ Sorts numerically (100 before 500)
// We format the visual ONLY. The underlying data remains a number.
cell: ({ value }) => (
),
}),
// E. Status Badge
columnHelper.accessor('status', {
header: 'Status',
width: 110,
features: {
pinning: true,
},
cell: ({ value }) => {
const palette: Record = {
active: 'success',
inactive: 'page',
on_leave: 'info',
}
return {value.replace('_', ' ').toUpperCase()}
},
}),
// F. Display Column (Right Pinned Actions)
columnHelper.display({
id: 'actions',
header: 'Actions',
width: 125,
features: {
pinning: true,
},
cell: () => (
),
}),
]
```
--------------------------------
### CSS example to limit max-height using available-height
Source: https://cerberus.digitalu.design/docs/components/popover
Shows how to use the --available-height CSS variable to ensure the popover content's maximum height does not exceed the available viewport height.
```css
[data-part='content'] {
max-height: calc(var(--available-height) - 100px);
}
```
--------------------------------
### Install Cerberus Panda Preset with pnpm
Source: https://cerberus.digitalu.design/docs/get-started/installation
Use this command to add the @cerberus/panda-preset package to your project using pnpm. pnpm has first-class support for JSR packages.
```bash
pnpm add jsr:@cerberus/panda-preset
```
--------------------------------
### Generated CSS for color-mix opacity
Source: https://cerberus.digitalu.design/docs/styling/color-opacity-modifier
The generated CSS output for the previous example. It uses `color-mix(in srgb, var(--colors-danger-bg-initial) 40%, transparent)` and sets the background color with a fallback to the original color variable.
```css
.css-sxdf {
--mix-background: color-mix(
in srgb,
var(--colors-danger-bg-initial) 40%,
transparent
);
background-color: var(--mix-background, var(--colors-danger-bg-initial));
color: var(--colors-danger-text-initial);
}
```
--------------------------------
### Run Cerberus script with Deno
Source: https://cerberus.digitalu.design/docs/get-started/installation
Runs the custom up:cerberus script using Deno.
```bash
deno run npm:up:cerberus
```
--------------------------------
### Transition prop with hardcoded and shortcut values
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `transition` prop to control the transition of an element. The first example uses a hardcoded transition value, while the second uses the shortcut value `backgrounds`.
```jsx
// hardcoded value
Hover me
// shortcut value
Hover me
```
--------------------------------
### Use cerberus. syntax to create JSX elements with styles and props
Source: https://cerberus.digitalu.design/docs/styling/cerberus-factory
Use 'cerberus.' JSX element syntax to create elements that support 'css', 'asChild', and style props. Example applies backgroundColor, hover styles, and a data attribute selector.
```javascript
import { cerberus } from '@cerberus/react'
function Example() {
return (
Click me
)
}
```
--------------------------------
### Run prepare with pnpm
Source: https://cerberus.digitalu.design/docs/styling/layer-styles
Run the prepare script using pnpm.
```bash
pnpm run prepare
```
--------------------------------
### Configure Vitest in vite.config.ts
Source: https://cerberus.digitalu.design/docs/components/testing
Create vite.config.ts to configure Vitest with globals enabled, jsdom environment, and a setup file. Setting globals: true automatically imports Vitest globals, removing the need to import expect, test, describe, etc.
```typescript
import { defineConfig } from 'vitest/config'
export default defineConfig({
// ...
test: {
globals: true,
environment: 'jsdom',
setupFiles: './setup-test.ts',
},
})
```
--------------------------------
### Get today's date with today
Source: https://cerberus.digitalu.design/docs/components/date-picker
Gets the current date in a format that the DatePicker can understand using the today function from @cerberus/react. Shows usage with a specific time zone and the local time zone.
```javascript
import { today, getLocalTimeZone } from '@cerberus/react'
const nyDate = today('America/New_York')
const localDate = today(getLocalTimeZone())
```
--------------------------------
### Import createQuery and useQuery
Source: https://cerberus.digitalu.design/docs/signals/create-query
Import the createQuery and useQuery functions from the @cerberus/signals package.
```javascript
import { createQuery, useQuery } from '@cerberus/signals'
```
--------------------------------
### animationDelay prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `animationDelay` prop to control the delay of an animation. The example sets it to `fast`.
```jsx
```
--------------------------------
### Import useQuery
Source: https://cerberus.digitalu.design/docs/signals/use-query
Import the useQuery hook from the @cerberus/signals package.
```APIDOC
import { useQuery } from '@cerberus/signals'
```
--------------------------------
### animationDuration prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `animationDuration` prop to control the duration of an animation. The example sets it to `fast`.
```jsx
```
--------------------------------
### Padding logical axis with paddingStart/End and shorthands
Source: https://cerberus.digitalu.design/docs/styling/spacing
Use the `padding{Start,End}` props to apply padding on the logical axis of an element based on text direction. Shorthands `ps` and `pe` are available. PandaCSS automatically translates pl/r/t/b to start/end/block properties.
```jsx
// shorthand
// shorthand
```
--------------------------------
### animation prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `animation` prop to control the animation of an element. The example sets it to `bounce`.
```jsx
```
--------------------------------
### Import createStoreContext
Source: https://cerberus.digitalu.design/docs/signals/create-store-context
Import the createStoreContext primitive from @cerberus/signals to create Context-based signal stores.
```javascript
import { createStoreContext } from '@cerberus/signals'
```
--------------------------------
### transitionDuration prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `transitionDuration` prop to control the duration of a transition. The example sets it to `fast`.
```jsx
Hover me
```
--------------------------------
### Style elements based on data-active attribute
Source: https://cerberus.digitalu.design/docs/styling/conditional-styles
Example of using the _active modifier for the data-active attribute.
```jsx
Hello
```
--------------------------------
### animationTimingFunction prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `animationTimingFunction` prop to control the timing function of an animation. The example sets it to `ease-in-out`.
```jsx
```
--------------------------------
### Run Cerberus script with Bun
Source: https://cerberus.digitalu.design/docs/get-started/installation
Runs the custom up:cerberus script using Bun.
```bash
bun run up:cerberus
```
--------------------------------
### transitionTimingFunction prop
Source: https://cerberus.digitalu.design/docs/styling/transitions
Use the `transitionTimingFunction` prop to control the timing function of a transition. The example sets it to `ease-in-out`.
```jsx
Hover me
```
--------------------------------
### Define theme with breakpoints, tokens, semantic tokens, and keyframes
Source: https://cerberus.digitalu.design/docs/theming/overview
Configures the system theme, defining breakpoints, primitive color tokens, a semantic token that consumes a primitive, and a spin keyframe animation.
```javascript
export default createCerberusConfig({
theme: {
breakpoints: {
sm: '320px',
md: '768px',
lg: '960px',
xl: '1200px',
},
tokens: {
colors: {
red: '#EE0F0F',
},
},
semanticTokens: {
colors: {
customRed: { value: '{colors.red}' },
},
},
keyframes: {
spin: {
from: { transform: 'rotate(0deg)' },
to: { transform: 'rotate(360deg)' },
},
},
},
})
```
--------------------------------
### Background Position with bgPosition
Source: https://cerberus.digitalu.design/docs/styling/background
Properties for controlling the position of a background image. The example sets `bgPosition` to `center`.
```jsx
```
--------------------------------
### Unmount on Exit example
Source: https://cerberus.digitalu.design/docs/components/presence
Use the unmountOnExit prop to remove the child component from the DOM when it's not present.
```tsx
'use client'
import { Presence } from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
export const UnmountOnExit = () => {
const [present, setPresent] = useSignal(false)
return (
<>
Hidden and Unmounted on Exit
>
)
}
```
--------------------------------
### Custom srcDoc Example
Source: https://cerberus.digitalu.design/docs/components/frame
Use the srcDoc prop to specify the HTML content of the page to use in the iframe.
```html
Hello from inside the frame!
This content is rendered within our custom frame component using a Portal.
The frame has custom initial content, including Font Awesome and Open Sans font.
`}>
```
--------------------------------
### Use useQuery with initialData
Source: https://cerberus.digitalu.design/docs/signals/use-query
Use the useQuery hook with a query factory and initialData option.
```APIDOC
const user = useQuery(queryUser(props.id), { initialData: props.initialData })
```
--------------------------------
### strictTokens usage examples
Source: https://cerberus.digitalu.design/docs/theming/overview
Contrasts a hardcoded color that will throw a TS error with a valid design token reference.
```jsx
// ❌ This will throw a TS error
Hello World
// ✅ This will work
Hello World
```
--------------------------------
### Responsive CSS variables using base and lg keys
Source: https://cerberus.digitalu.design/docs/styling/css-vars
Uses the responsive syntax with `base` and `lg` keys to make the `--font-size` variable responsive.
```jsx
Hello
Hello
```
--------------------------------
### Configure cssVarRoot
Source: https://cerberus.digitalu.design/docs/theming/overview
Sets the root element where token CSS variables are applied. The example sets it to ':where(:root, :host)'.
```javascript
export default createCerberusConfig({
cssVarRoot: ':where(:root, :host)',
})
```
--------------------------------
### Import CerberusProvider, makeSystemConfig, defineIcons
Source: https://cerberus.digitalu.design/docs/components/cerberus-context
Import the necessary functions from the Cerberus React package to use the context provider and configuration helpers.
```typescript
import { CerberusProvider, makeSystemConfig, defineIcons } from '@cerberus/react'
```
--------------------------------
### Background Repeat with bgRepeat
Source: https://cerberus.digitalu.design/docs/styling/background
Use `bgRepeat` or `backgroundRepeat` to control the repeat of a background image. The example sets it to `no-repeat`.
```jsx
```
--------------------------------
### Generate theme typings with Panda CLI (Deno)
Source: https://cerberus.digitalu.design/docs/theming/slot-recipes
Run this command in your terminal to generate theme typings for your recipes using the Panda CLI with Deno.
```bash
deno panda npm:codegen
```
--------------------------------
### Background Origin with bgOrigin
Source: https://cerberus.digitalu.design/docs/styling/background
Use `bgOrigin` or `backgroundOrigin` to control the origin of a background image. The example sets it to `border-box`.
```jsx
```
--------------------------------
### Background Clip with bgClip
Source: https://cerberus.digitalu.design/docs/styling/background
Use the `bgClip` prop to control the clipping of a background image. The example sets it to `border-box`.
```jsx
```
--------------------------------
### Generate theme typings with Panda CLI (Bun)
Source: https://cerberus.digitalu.design/docs/theming/slot-recipes
Run this command in your terminal to generate theme typings for your recipes using the Panda CLI with Bun.
```bash
bun panda codegen
```
--------------------------------
### Background Attachment with bgAttachment
Source: https://cerberus.digitalu.design/docs/styling/background
Use the `bgAttachment` prop to control the attachment of a background image. The example sets it to `fixed`.
```jsx
```
--------------------------------
### Import Cq component
Source: https://cerberus.digitalu.design/docs/components/container-query
Import the Cq component from the styled-system/jsx module.
```javascript
import { Cq } from 'styled-system/jsx'
```
--------------------------------
### Lazy Mount example
Source: https://cerberus.digitalu.design/docs/components/presence
Use the lazyMount prop to delay mounting of the child component until the present prop is set to true.
```tsx
'use client'
import { Presence } from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
export const LazyMount = () => {
const [present, setPresent] = useSignal(false)
return (
<>
Unmounted and Hidden
>
)
}
```
--------------------------------
### Background Gradient with bgGradient
Source: https://cerberus.digitalu.design/docs/styling/background
Properties to create a background gradient based on color stops. The example uses `to-r` with `gradientFrom` and `gradientTo`.
```jsx
```
--------------------------------
### Generate theme typings with Panda CLI (npm)
Source: https://cerberus.digitalu.design/docs/theming/slot-recipes
Run this command in your terminal to generate theme typings for your recipes using the Panda CLI with npm.
```bash
npm panda codegen
```