### 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 ( Product Category Price {(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 ( Rounded Block ) } ``` -------------------------------- ### 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 ( Small Small Medium Medium Large Large ) } ``` -------------------------------- ### 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 ( Edit Content Make changes to your content. You'll be asked to confirm before closing if there are unsaved changes.