### Install with Bun
Source: https://cerberus.digitalu.design/docs/signals/overview
Use this command to install the Signals library using Bun.
```bash
bun add @cerberus/signals@npm:@cerberus-design/signals
```
--------------------------------
### Install with Deno
Source: https://cerberus.digitalu.design/docs/signals/overview
Use this command to install the Signals library using Deno.
```bash
deno add npm:@cerberus/signals@npm:@cerberus-design/signals
```
--------------------------------
### Install Cerberus React with Deno
Source: https://cerberus.digitalu.design/docs/get-started/installation
Install the Cerberus React library using Deno.
```bash
deno add npm:@cerberus-design/react
```
--------------------------------
### Install Data Grid with Deno
Source: https://cerberus.digitalu.design/docs/data-grid/overview
Use this command to install the Data Grid package using Deno.
```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
Use this command to install the Data Grid package using Bun.
```bash
bun add @cerberus/data-grid@npm:@cerberus-design/data-grid
```
--------------------------------
### Install with NPM
Source: https://cerberus.digitalu.design/docs/signals/overview
Use this command to install the Signals library using NPM.
```bash
npm install @cerberus/signals@npm:@cerberus-design/signals
```
--------------------------------
### Install with PNPM
Source: https://cerberus.digitalu.design/docs/signals/overview
Use this command to install the Signals library using PNPM.
```bash
pnpm add @cerberus/signals@npm:@cerberus-design/signals
```
--------------------------------
### Basic Data Grid Setup
Source: https://cerberus.digitalu.design/docs/data-grid/sort
This snippet shows the basic setup for the Data Grid component, including importing necessary modules and rendering the grid with columns and data. It serves as a foundation for adding features like sorting.
```javascript
'use client'
import { DataGrid } from '@cerberus/data-grid'
import { Box } from 'styled-system/jsx'
import { createFakeQuery } from '../quick-start/data'
import { columns } from './columns'
export function BasicDemo() {
// Normally this would be from useQuery or a server-side API call
const data = createFakeQuery(1000)
return (
)
}
```
--------------------------------
### Install Data Grid with NPM
Source: https://cerberus.digitalu.design/docs/data-grid/overview
Use this command to install the Data Grid package using NPM.
```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
Use this command to install the Data Grid package using PNPM.
```bash
pnpm add @cerberus/data-grid@npm:@cerberus-design/data-grid
```
--------------------------------
### Install Cerberus React with Bun
Source: https://cerberus.digitalu.design/docs/get-started/installation
Install the Cerberus React library using Bun, creating an alias for the package name.
```bash
bun add @cerberus/react@npm:@cerberus-design/react
```
--------------------------------
### Basic Cerberus Provider Setup
Source: https://cerberus.digitalu.design/docs/components/cerberus-context
Wrap your application or a section of it with CerberusProvider to enable context.
```javascript
'use client'
import { CerberusProvider } from '@cerberus/react'
import { type PropsWithChildren } from 'react'
export function CerberusConfig(props: PropsWithChildren) {
return {props.children}
}
```
--------------------------------
### Basic Usage
Source: https://cerberus.digitalu.design/docs/components/switch
A simple example of how to use the Switch component to receive in-app notifications.
```APIDOC
## Basic Usage
### Description
This demonstrates the basic implementation of the Switch component for a simple toggle functionality.
### Component
```jsx
import { Switch } from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function BasicDemo() {
return (
Receive in app notifications
)
}
```
```
--------------------------------
### Basic Theme Examples
Source: https://cerberus.digitalu.design/docs/components/theme
Demonstrates applying different modes (light, dark, system) and a custom theme ('acheron') using the Theme component.
```javascript
import { Button, Theme } from '@cerberus/react'
import { Box, VStack } from 'styled-system/jsx'
function BasicExample() {
return (
)
}
```
--------------------------------
### Install Cerberus React with NPM
Source: https://cerberus.digitalu.design/docs/get-started/installation
Install the Cerberus React library using NPM, creating an alias for the package name.
```bash
npm install @cerberus/react@npm:@cerberus-design/react
```
--------------------------------
### Setup Test File
Source: https://cerberus.digitalu.design/docs/components/testing
Create a setup-test.ts file to configure the testing environment and mock unimplemented APIs. This includes mocks for ResizeObserver, IntersectionObserver, scroll methods, and more.
```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 Testing Dependencies
Source: https://cerberus.digitalu.design/docs/components/testing
Install Vitest, jsdom, and testing-library packages for component testing. These are essential for setting up your testing environment.
```bash
npm install --save-dev vitest jsdom @testing-library/dom @testing-library/jest-dom @testing-library/react @testing-library/user-event
```
--------------------------------
### Install Cerberus React with PNPM
Source: https://cerberus.digitalu.design/docs/get-started/installation
Install the Cerberus React library using PNPM, creating an alias for the package name.
```bash
pnpm add @cerberus/react@npm:@cerberus-design/react
```
--------------------------------
### Basic Table Example
Source: https://cerberus.digitalu.design/docs/components/table
Displays a basic table with product information. Use this for standard data presentation. Ensure 'For' component is imported for iteration.
```javascript
import { Table, For } from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function BasicTablePreview() {
const items = [
{ id: 1, name: 'Laptop', category: 'Electronics', price: 999.99 },
{ id: 2, name: 'Coffee Maker', category: 'Home Appliances', price: 49.99 },
{ id: 3, name: 'Desk Chair', category: 'Furniture', price: 150.0 },
{ id: 4, name: 'Smartphone', category: 'Electronics', price: 799.99 },
{ id: 5, name: 'Headphones', category: 'Accessories', price: 199.99 },
]
return (
ProductCategoryPrice
{(item) => (
{item.name}{item.category}{item.price}
)}
)
}
```
--------------------------------
### Download SVG File
Source: https://cerberus.digitalu.design/docs/components/download-trigger
This example demonstrates downloading an SVG file. The SVG content is provided as a string to the `data` prop.
```jsx
import { DownloadTrigger } from '@cerberus/react'
export const Svg = () => {
return (
Download SVG
)
}
```
--------------------------------
### Basic EnvironmentProvider Setup
Source: https://cerberus.digitalu.design/docs/components/environment
Render the EnvironmentProvider to wrap your application and provide the necessary context for Ark UI components to function correctly in custom environments.
```jsx
import { EnvironmentProvider } from '@cerberus/react'
import Frame from 'react-frame-component'
export const App = () => {
return (
{/* Your App */}
)
}
```
--------------------------------
### Skeleton Loading State Example
Source: https://cerberus.digitalu.design/docs/components/loading-states
This example demonstrates a complex skeleton loading state using various components and the `aria-busy` attribute to indicate loading.
```jsx
import { Tag, Text } from '@cerberus/react'
import { Box, Circle, HStack, VStack } from 'styled-system/jsx'
import { css } from 'styled-system/css'
export function OverviewPreview() {
return (
This is a description of something.Trash content
Trash content is a place where you can find all the content that you
have deleted. You can restore or permanently delete the content from
here.
Skeleton
)
}
```
--------------------------------
### Live Text Gradient Examples
Source: https://cerberus.digitalu.design/docs/styling/text-gradient
Demonstrates various text gradient applications using different tokens and components. Imports include `cerberus` and `css` from 'styled-system/css'.
```jsx
import { cerberus } from '@cerberus/react'
import { css } from 'styled-system/css'
export default function TextGradientPreview() {
return (
Charon Dark Gradient
This text uses the Charon light gradient variant.
Nyx dark gradient creates a striking effect.
Amphiaraus light gradient for subtle elegance.
)
}
```
--------------------------------
### Container Sizes with maxWidth Prop
Source: https://cerberus.digitalu.design/docs/components/container
Illustrates how to control the size of the Container using the `maxWidth` prop, with examples for '1/4', '1/2', '3/4', and 'full' widths.
```javascript
import { Container, VStack } from 'styled-system/jsx'
import { DecorativeBox } from '@/app/components/decorative-box'
function getText(size: string) {
return `This is some text within a container of size ${size}.`
}
export function SizesDemo() {
return (
{getText('1/4')}{getText('1/2')}{getText('3/4')}{getText('full')}
)
}
```
--------------------------------
### Query with Initial Data
Source: https://cerberus.digitalu.design/docs/signals/use-query
Bypass the initial fetch by providing `initialData` in the options object. This is useful for pre-loading data, for example, from a server component.
```javascript
'use client'
import { useQuery } from '@cerberus/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}
}
```
--------------------------------
### Pin Input Sizes
Source: https://cerberus.digitalu.design/docs/components/pin-input
Apply different sizes to the PinInput component using the `size` prop. This example demonstrates 'md' and 'lg' sizes.
```javascript
import { PinInput, Field } from '@cerberus/react'
import { HStack } from 'styled-system/jsx'
export function SizesPreview() {
return (
)
}
```
--------------------------------
### Setup Data Grid Columns
Source: https://cerberus.digitalu.design/docs/data-grid/quickstart
Set up strictly typed columns for the Data Grid using `createColumnHelper`. Pass your data type to `createColumnHelper` to define columns.
```typescript
import { createColumnHelper } from '@cerberus/data-grid'
import { type Employee } from './data.demo'
export const columnHelper = createColumnHelper()
```
--------------------------------
### Accordion Indicator Position
Source: https://cerberus.digitalu.design/docs/components/accordion
Customize the indicator position of AccordionItemGroup to 'start' or 'end'. This example shows the indicator positioned at the start.
```javascript
import {
Accordion,
AccordionItemGroup,
For,
Show,
} from '@cerberus/react'
import { Box } from 'styled-system/jsx'
import data from './data.json'
export function IndicatorDemo() {
return (
{(item) => (
{item.content}
)}
)
}
```
--------------------------------
### Create a Global Clock Store
Source: https://cerberus.digitalu.design/docs/signals/stores
Define a store function that returns an object containing signals and actions. This example demonstrates a clock store with time-related signals and a function to start the clock.
```typescript
'use client'
import { HStack } from '@/styled-system/jsx'
import { Button } from '@cerberus/react'
import {
batch,
createComputed,
createEffect,
createSignal,
ReactiveText,
type Accessor,
} from '@cerberus/signals'
type ClockStore = {
time: Accessor
hours: Accessor
minutes: Accessor
seconds: Accessor
shortTime: Accessor
startClock: () => void
}
export function globalStoreDemo(): ClockStore {
const [hours, setHours] = createSignal(0)
const [minutes, setMinutes] = createSignal(0)
const [seconds, setSeconds] = createSignal(0)
const [turnOn, setTurnOn] = createSignal(false)
const time = createComputed(() => `${hours()}:${minutes()}:${seconds()}`)
const shortTime = createComputed(() => `${hours()}:${minutes()}`)
function getTime() {
const now = new Date()
setHours(now.getHours())
setMinutes(now.getMinutes())
setSeconds(now.getSeconds())
}
createEffect(() => {
if (turnOn()) {
const interval = setInterval(() => getTime(), 1000)
return () => clearInterval(interval)
}
})
return {
time,
shortTime,
hours,
minutes,
seconds,
// actions
startClock: () => {
batch(() => {
setTurnOn(true)
getTime()
})
},
}
}
export function GlobalDemo() {
const store = globalStoreDemo()
return (
)
}
```
--------------------------------
### Progress Bar Usage Examples
Source: https://cerberus.digitalu.design/docs/components/progress
Demonstrates the use of the ProgressBar component in both rounded and block styles. Ensure to import necessary components like Tag, HStack, and VStack.
```javascript
import { ProgressBar, Tag } from '@cerberus/react'
import { HStack, VStack } from 'styled-system/jsx'
export function OverviewPreview() {
return (
RoundedBlock
)
}
```
--------------------------------
### Combobox with Start Icon
Source: https://cerberus.digitalu.design/docs/components/combobox
Adds a start icon to the Combobox input using the `startIcon` prop. This is useful for visual cues like a search icon.
```javascript
'use client'
import {
For,
Combobox,
ComboItemWithIndicator,
ComboItemText,
useStatefulCollection,
} from '@cerberus/react'
import { Box, VStack } from 'styled-system/jsx'
import { useMemo, useState } from 'react'
import { Search } from '@carbon/icons-react'
const initialItems = [
{ label: 'Hades', value: 'hades' },
{ label: 'Persephone', value: 'persephone' },
{ label: 'Zeus', value: 'zeus', disabled: true },
{ label: 'Poseidon', value: 'poseidon' },
{ label: 'Hera', value: 'hera' },
]
function StartIconPreview() {
const { collection, handleInputChange } = useStatefulCollection(initialItems)
return (
}
>
No results found
}
>
{(item) => (
{item.label}
)}
)
}
```
--------------------------------
### Get Today's Date
Source: https://cerberus.digitalu.design/docs/components/date-picker
Use the `today` function to get the current date in a format that the `DatePicker` can understand. You can specify a timezone or use the local timezone.
```javascript
import { today, getLocalTimeZone } from '@cerberus/react'
const nyDate = today('America/New_York');
const localDate = today(getLocalTimeZone());
```
--------------------------------
### Table Sizes Example
Source: https://cerberus.digitalu.design/docs/components/table
Demonstrates how to set different sizes for table cells using the 'size' prop on Table.Root. Available sizes are 'sm', 'md', and 'lg'. The default is 'md'.
```javascript
import { Table, For } from '@cerberus/react'
import { HStack } from 'styled-system/jsx'
function SizesPreview() {
return (
SmallSmallMediumMediumLargeLarge
)
}
```
--------------------------------
### Strict Token Usage Example
Source: https://cerberus.digitalu.design/docs/theming
Illustrates the effect of `strictTokens`. The first example shows an invalid usage with a hardcoded color, while the second shows the correct usage with a defined token.
```javascript
// ❌ This will throw a TS error
Hello World
// ✅ This will work
Hello World
```
--------------------------------
### Confirmation Dialog Example
Source: https://cerberus.digitalu.design/docs/components/dialog
This example demonstrates how to create a confirmation dialog that intercepts close attempts on a parent dialog. It prevents data loss by showing a confirmation prompt if there are unsaved changes in the parent dialog.
```typescript
'use client'
import { Stack } from '@/styled-system/jsx'
import {
Button,
ButtonGroup,
Dialog,
DialogCloseIconTrigger,
DialogDescription,
DialogHeading,
DialogRootProvider,
DialogRootProviderProps,
Field,
Text,
Textarea,
useDialog,
} from '@cerberus/react'
import { useSignal } from '@cerberus/signals'
import { ChangeEventHandler } from 'react'
export function ConfirmationDialog() {
const [formContent, setFormContent] = useSignal('')
const [isParentDialogOpen, setIsParentDialogOpen] = useSignal(false)
const parentDialog = useDialog({
open: isParentDialogOpen,
onOpenChange: (details) => {
if (!details.open && formContent.trim()) {
confirmDialog.setOpen(true)
} else {
setIsParentDialogOpen(details.open)
}
},
})
const confirmDialog = useDialog()
const handleConfirmClose = () => {
confirmDialog.setOpen(false)
parentDialog.setOpen(false)
setFormContent('')
}
const handleCancel = () => {
confirmDialog.setOpen(false)
}
return (
<>
setFormContent(e.target.value)}
formValue={formContent}
value={parentDialog}
/>
>
)
}
interface ParentDialogProps extends DialogRootProviderProps {
onChange?: ChangeEventHandler
formValue: string
}
function ParentDialog(props: ParentDialogProps) {
return (
)
}
interface ConfirmationDialogProps extends DialogRootProviderProps {
onCancel?: () => void
onClose?: () => void
}
function ConfirmDialog(props: ConfirmationDialogProps) {
return (
)
}
```
--------------------------------
### Custom Select with Primitives
Source: https://cerberus.digitalu.design/docs/components/select
Demonstrates how to build a custom select component using individual primitives. This example shows custom styling for the label, control, trigger, and content, along with dynamic item rendering.
```javascript
function SelectCustomPreview() {
const collection = createSelectCollection([
{ label: 'Hades', value: '1-hades' },
{ label: 'Persephone', value: '1-persephone' },
{ label: 'Zeus', value: '1-zeus', disabled: true },
{ label: 'Poseidon', value: '1-poseidon' },
{ label: 'Hera', value: '1-hera' },
])
return (
Select a custom relative
Clear
The fam
{(item, idx) => (
{item.label}
✓
)}
)
}
```
--------------------------------
### Basic Select Usage
Source: https://cerberus.digitalu.design/docs/components/select
Demonstrates the basic usage of the Select component with a list of options. Ensure the collection is created using `createSelectCollection`.
```javascript
import {
For,
Field,
Select,
Option,
createSelectCollection
} from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function SelectBasicPreview() {
const collection = createSelectCollection([
{ label: 'Hades', value: 'hades' },
{ label: 'Persephone', value: 'persephone' },
{ label: 'Zeus', value: 'zeus', disabled: true },
{ label: 'Poseidon', value: 'poseidon' },
{ label: 'Hera', value: 'hera' },
])
return (
)
}
```
--------------------------------
### Field Group Example
Source: https://cerberus.digitalu.design/docs/components/fieldset
Illustrates using the Fieldset component with the 'fieldGroup' usage for grouping radio inputs.
```APIDOC
## Fieldset Component - Field Group Example
### Description
This example demonstrates using the `Fieldset` component with `usage="fieldGroup"` to label a group of `Radio` inputs.
### Props
- **legend** (string) - Required - The main label for the fieldset group.
- **usage** (string) - Optional - Specifies the type of fieldset. Defaults to `"fieldGroup"`.
### Request Example
```javascript
import {
Fieldset,
RadioGroup,
Radio,
} from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function FieldsetGroupDemo() {
return (
)
}
```
```
--------------------------------
### Basic Usage
Source: https://cerberus.digitalu.design/docs/components/icon-button
Demonstrates the basic implementation of the IconButton component.
```APIDOC
## Basic Usage
### Description
This snippet shows how to import and use the `IconButton` component with an icon.
### Component
```jsx
import { IconButton } from '@cerberus/react'
import { Tuning } from '@carbon/icons-react'
function BasicButtonPreview() {
return
}
```
```
--------------------------------
### Closable Tag Example
Source: https://cerberus.digitalu.design/docs/components/tag
Implements a closable tag by providing an 'onClick' prop. This automatically adds a close icon.
```javascript
'use client'
import { Tag } from '@cerberus/react'
import { HStack } from 'styled-system/jsx'
function ClosableTagPreview() {
const handleClose = () => {
console.log('Tag closed')
}
return (
Closable
Closable
Closable
)
}
```
--------------------------------
### Basic Data Grid Demo
Source: https://cerberus.digitalu.design/docs/data-grid/filtering
This snippet demonstrates the basic setup of the Data Grid component with sample data and columns. Ensure the 'filter' feature is enabled in column definitions for filtering to be available.
```javascript
'use client'
import { DataGrid } from '@cerberus/data-grid'
import { Box } from 'styled-system/jsx'
import { createFakeQuery } from '../quick-start/data'
import { columns } from './columns'
export function BasicDemo() {
const data = createFakeQuery(1000)
return (
)
}
// columnHelper.accessor('id', {
// header: 'ID',
// width: 80,
// features: {
// pinning: {
// defaultPosition: 'left',
// },
// sort: true,
// filter: true,
// },
// cell: ({ value }) => #{value},
// })
```
--------------------------------
### Form Section Example
Source: https://cerberus.digitalu.design/docs/components/fieldset
Demonstrates using the Fieldset component to group related form elements in a 'formSection' usage.
```APIDOC
## Fieldset Component - Form Section Example
### Description
This example shows how to use the `Fieldset` component to group form fields for a profile update section. It utilizes the `usage="formSection"` prop to define its purpose.
### Props
- **invalid** (boolean) - Optional - Indicates if the fieldset has an invalid state.
- **legend** (string) - Required - The main label for the fieldset group.
- **helperText** (string) - Optional - Provides additional descriptive text for the fieldset.
- **errorText** (string) - Optional - Displays an error message when the fieldset is in an invalid state.
- **usage** (string) - Optional - Specifies the type of fieldset. Accepts `"formSection"` or `"fieldGroup"` (default).
### Request Example
```javascript
import {
Fieldset,
Field,
Input,
RadioGroup,
Radio,
} from '@cerberus/react'
import { Box, VStack } from 'styled-system/jsx'
export function BasicDemo() {
return (
)
}
```
```
--------------------------------
### Date Range Picker Usage
Source: https://cerberus.digitalu.design/docs/components/date-picker
Example of a date range picker. Set selectionMode to 'range' and use RangePickerInput.
```javascript
import {
DatePicker,
DatePickerLabel,
RangePickerInput,
DatePickerCalendar,
Field,
} from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function RangePreview() {
return (
Search range
)
}
```
--------------------------------
### Basic Usage
Source: https://cerberus.digitalu.design/docs/components/highlight
Demonstrates the basic usage of the Highlight component with a single query.
```APIDOC
## Highlight Component
### Description
The Highlight component renders text with specified portions highlighted.
### Props
- **text** (string) - Required - The full text content to be displayed.
- **query** (string) - Required - The text to be highlighted within the `text` prop.
### Example
```javascript
import { Highlight } from '@cerberus/react'
export const Basic = () => {
return (
)
}
```
```
--------------------------------
### Show Portal Example
Source: https://cerberus.digitalu.design/docs/components/portal
Demonstrates how to use the Portal component to display content outside the DOM hierarchy. Use this when you need to render elements that should not be constrained by their parent's styling or DOM structure.
```javascript
'use client'
import { Close } from '@carbon/icons-react'
import { Button, IconButton, Portal, Show } from '@cerberus/react'
import { hstack } from 'styled-system/patterns'
import { useState } from 'react'
function PortalPreview() {
const [showPortal, setShowPortal] = useState(false)
function handleShowPortal() {
setShowPortal(true)
}
function handleClosePortal() {
setShowPortal(false)
}
return (
<>
This is a portal element that is outside of the DOM hierarchy of
the parent component.
>
)
}
```
--------------------------------
### Field Group Example with Fieldset
Source: https://cerberus.digitalu.design/docs/components/fieldset
Use the Fieldset component with the default `usage='fieldGroup'` to label a group of Radio or Checkbox inputs.
```javascript
import {
Fieldset,
RadioGroup,
Radio,
} from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function FieldsetGroupDemo() {
return (
)
}
```
--------------------------------
### Create a Customized Table with Data
Source: https://cerberus.digitalu.design/docs/components/table
This example demonstrates how to create a customized table using the `Table` component from '@cerberus/react'. It includes defining columns and data, and applying custom CSS for styling the table, header cells, and body cells.
```javascript
import { Table, For } from '@cerberus/react'
function CustomizedPreview() {
const cols = [
{ id: '1', name: 'Cerberus Family' },
{ id: '2', name: 'Alias' },
]
const data = [
{ id: '1', name: 'Cerberus', alias: 'The Three-Headed Dog' },
{ id: '2', name: 'Hades', alias: 'God of the Underworld' },
{ id: '3', name: 'Persephone', alias: 'Queen of the Underworld' },
{ id: '4', name: 'Charon', alias: 'The Ferryman' },
{ id: '5', name: 'Cerberus', alias: 'The Guardian of the Underworld' },
{ id: '6', name: 'Thanatos', alias: 'God of Death' },
]
return (
{(col) => (
{col.name}
)}
{(item) => (
{item.name}
{item.alias}
)}
)
}
```
--------------------------------
### Single Date Picker Usage
Source: https://cerberus.digitalu.design/docs/components/date-picker
Example of a controlled single date picker. Ensure to import Field and Box for layout.
```javascript
import {
DatePicker,
DatePickerLabel,
DatePickerInput,
DatePickerCalendar,
Field,
} from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function StaticPreview() {
return (
Start date
)
}
```
--------------------------------
### Initial Data
Source: https://cerberus.digitalu.design/docs/signals/use-query
Illustrates how to provide initial data to the useQuery hook, bypassing the initial fetch and immediately seeding the cache with pre-loaded data. This is useful when data is fetched on the server.
```APIDOC
## Initial Data
If you would like to bypass the initial fetch with pre-loaded data that matches the return of the query factory being used (e.g., parent server component fetch) - add and options Object as the last argument with the property `initialData`.
```
```typescript
'use client'
import { useQuery } from '@cerberus/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}
}
```
--------------------------------
### Configure Vitest
Source: https://cerberus.digitalu.design/docs/components/testing
Configure Vitest in your vite.config.ts file. Set the environment to 'jsdom' and specify a setup file for custom configurations.
```typescript
import { defineConfig } from "vitest/config"
export default defineConfig({
// ...
test: {
globals: true,
environment: "jsdom",
setupFiles: "./setup-test.ts",
},
})
```