Skip to main content

Design Tokens

@cpod/tokens provides the complete CyberPod design system with CSS variables, Tailwind preset, and JavaScript/TypeScript exports for building consistent UIs.

Installation

npm install @cpod/tokens
# or
pnpm add @cpod/tokens
# or
yarn add @cpod/tokens

Design System Overview

The CyberPod design system includes:

  • 🎨 Colors - Light/dark theme, semantic colors, chart colors
  • ✍️ Typography - Font families, sizes, and weights
  • 📏 Spacing - Consistent spacing scale (4px base)
  • 🔵 Border Radius - Standard radius tokens
  • 🎭 Shadows - Elevation shadows
  • 📐 Breakpoints - Responsive design breakpoints
  • 🔄 Animations - Duration, easing, and keyframes

Usage Methods

Import CSS files and use variables directly:

/* Import in your global CSS */
@import "@cpod/tokens/css/variables.css";
@import "@cpod/tokens/css/themes.css";

/* Use in your styles */
.button {
background-color: var(--cpod-primary);
color: var(--cpod-primary-foreground);
border-radius: var(--cpod-radius);
padding: var(--cpod-spacing-3) var(--cpod-spacing-6);
}

2. Tailwind Preset

Use pre-configured Tailwind theme:

// tailwind.config.js
import { cyberpodPreset } from "@cpod/tokens";

export default {
presets: [cyberpodPreset],
content: ["./src/**/*.{js,ts,jsx,tsx}"],
};

Then use Tailwind classes with CyberPod tokens:

<button className="bg-primary text-primary-foreground rounded-md px-6 py-3">
Click me
</button>

3. JavaScript/TypeScript

Import tokens programmatically:

import { colors, spacing, typography } from "@cpod/tokens";

const styles = {
color: colors.primary,
fontSize: typography.sizes.md,
padding: spacing[4],
};

Color System

Theme Colors

Light Theme

TokenCSS VariableHexUsage
Primary--cpod-primaryhsl(222 47% 11%)Main brand color
Secondary--cpod-secondaryhsl(210 40% 96%)Secondary elements
Accent--cpod-accenthsl(210 40% 96%)Accent highlights
Destructive--cpod-destructivehsl(0 84% 60%)Error, delete actions
Muted--cpod-mutedhsl(210 40% 96%)Subtle backgrounds

Dark Theme

TokenCSS VariableHexUsage
Primary--cpod-primaryhsl(210 40% 98%)Main brand color
Secondary--cpod-secondaryhsl(217 33% 17%)Secondary elements
Accent--cpod-accenthsl(217 33% 17%)Accent highlights
Destructive--cpod-destructivehsl(0 63% 31%)Error, delete actions
Muted--cpod-mutedhsl(217 33% 17%)Subtle backgrounds

Usage Example

/* CSS */
.card {
background-color: var(--cpod-card);
border: 1px solid var(--cpod-border);
color: var(--cpod-card-foreground);
}

/* Tailwind */
<div className="bg-card border border-border text-card-foreground">
Card content
</div>

Semantic Colors

All color tokens include foreground variants:

  • --cpod-primary-foreground - Text on primary background
  • --cpod-secondary-foreground - Text on secondary background
  • --cpod-accent-foreground - Text on accent background
  • --cpod-destructive-foreground - Text on destructive background

Chart Colors

Special colors for data visualization:

var(--cpod-chart-1)  /* Blue */
var(--cpod-chart-2) /* Green */
var(--cpod-chart-3) /* Orange */
var(--cpod-chart-4) /* Purple */
var(--cpod-chart-5) /* Red */

Typography

Font Families

// CSS
font-family: var(--cpod-font-sans); /* Inter, system-ui */
font-family: var(--cpod-font-mono); /* JetBrains Mono, monospace */

// Tailwind
<p className="font-sans">Sans-serif text</p>
<code className="font-mono">Monospace code</code>

Font Sizes

TokenValueCSS VariableUsage
xs12px--cpod-text-xsFine print
sm14px--cpod-text-smSmall text
base16px--cpod-text-baseBody text
lg18px--cpod-text-lgLarge text
xl20px--cpod-text-xlHeadings
2xl24px--cpod-text-2xlLarge headings
3xl30px--cpod-text-3xlDisplay
4xl36px--cpod-text-4xlHero

Usage Example

// Tailwind
<h1 className="text-4xl font-bold">Hero Title</h1>
<p className="text-base">Body paragraph</p>
<span className="text-sm text-muted-foreground">Helper text</span>

// CSS
h1 {
font-size: var(--cpod-text-4xl);
font-weight: 700;
}

Spacing

4px base unit scale for consistent spacing.

TokenValueCSS Variable
00px--cpod-spacing-0
14px--cpod-spacing-1
28px--cpod-spacing-2
312px--cpod-spacing-3
416px--cpod-spacing-4
520px--cpod-spacing-5
624px--cpod-spacing-6
832px--cpod-spacing-8
1040px--cpod-spacing-10
1248px--cpod-spacing-12
1664px--cpod-spacing-16
2080px--cpod-spacing-20
2496px--cpod-spacing-24

Usage Example

// Tailwind (uses spacing scale automatically)
<div className="p-4 mt-6 mb-8">
<div className="space-y-3">...</div>
</div>

// CSS
.container {
padding: var(--cpod-spacing-4);
margin-top: var(--cpod-spacing-6);
gap: var(--cpod-spacing-3);
}

Border Radius

TokenValueCSS Variable
none0px-
sm4px--cpod-radius-sm
md8px--cpod-radius
lg12px--cpod-radius-lg
xl16px--cpod-radius-xl
2xl24px--cpod-radius-2xl
full9999px-

Usage Example

// Tailwind
<div className="rounded-md">Default radius</div>
<div className="rounded-lg">Large radius</div>
<div className="rounded-full">Circle/pill</div>

// CSS
.button {
border-radius: var(--cpod-radius);
}

.avatar {
border-radius: var(--cpod-radius-full);
}

Shadows

5 elevation levels for depth hierarchy.

TokenCSS VariableUsage
sm--cpod-shadow-smSubtle elevation
md--cpod-shadow-mdModerate elevation
lg--cpod-shadow-lgHigh elevation
xl--cpod-shadow-xlVery high elevation
2xl--cpod-shadow-2xlMaximum elevation

Usage Example

// Tailwind
<div className="shadow-md">Card with shadow</div>
<div className="shadow-lg hover:shadow-xl transition-shadow">
Interactive card
</div>

// CSS
.card {
box-shadow: var(--cpod-shadow-md);
}

.modal {
box-shadow: var(--cpod-shadow-2xl);
}

Breakpoints

Responsive design breakpoints for different screen sizes.

BreakpointValueCSSUsage
xs475px@media (min-width: 475px)Small phones
sm640px@media (min-width: 640px)Phones
md768px@media (min-width: 768px)Tablets
lg1024px@media (min-width: 1024px)Laptops
xl1280px@media (min-width: 1280px)Desktops
2xl1536px@media (min-width: 1536px)Large screens

Usage Example

// Tailwind (mobile-first)
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
...
</div>

<h1 className="text-2xl md:text-3xl lg:text-4xl">
Responsive heading
</h1>

// CSS
@media (min-width: 768px) {
.container {
max-width: 720px;
}
}

Animations

Duration

TokenValueUsage
fast150msQuick transitions
normal300msStandard transitions
slow500msSmooth transitions

Easing

--cpod-ease-in: cubic-bezier(0.4, 0, 1, 1);
--cpod-ease-out: cubic-bezier(0, 0, 0.2, 1);
--cpod-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

Keyframes

Predefined animations like fade-in, slide-in, etc.

Usage Example

// Tailwind
<div className="transition-all duration-300 ease-in-out hover:scale-105">
Smooth hover effect
</div>

// CSS
.button {
transition: background-color 300ms var(--cpod-ease-in-out);
}

.button:hover {
background-color: var(--cpod-primary-hover);
}

Customization

Override CSS Variables

Create a custom theme by overriding variables:

:root {
/* Custom primary color */
--cpod-primary: hsl(280 100% 70%);
--cpod-primary-foreground: hsl(0 0% 100%);

/* Custom radius */
--cpod-radius: 16px;

/* Custom font */
--cpod-font-sans: "Your Font", system-ui, sans-serif;
}

Extend Tailwind Preset

Add custom tokens alongside CyberPod tokens:

// tailwind.config.js
import { cyberpodPreset } from "@cpod/tokens";

export default {
presets: [cyberpodPreset],
theme: {
extend: {
colors: {
brand: "#your-color",
},
spacing: {
128: "32rem",
},
},
},
};

Complete Integration Example

Next.js with Tailwind

// tailwind.config.ts
import type { Config } from "tailwindcss";
import { cyberpodPreset } from "@cpod/tokens";

const config: Config = {
presets: [cyberpodPreset],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
};

export default config;
// app/page.tsx
import { Button, Card, CardContent } from "@cpod/react";

export default function Home() {
return (
<div className="min-h-screen bg-background px-6 py-12">
<div className="mx-auto max-w-4xl">
<h1 className="text-4xl font-bold text-foreground mb-6">
Welcome to CyberPod
</h1>

<div className="grid gap-6 md:grid-cols-2">
<Card>
<CardContent className="p-6">
<h2 className="text-2xl font-semibold mb-3">
Consistent Design
</h2>
<p className="text-muted-foreground mb-4">
Use design tokens for a unified look across your app.
</p>
<Button variant="default">Get Started</Button>
</CardContent>
</Card>

<Card>
<CardContent className="p-6">
<h2 className="text-2xl font-semibold mb-3">
Fully Typed
</h2>
<p className="text-muted-foreground mb-4">
TypeScript support with auto-completion.
</p>
<Button variant="outline">Learn More</Button>
</CardContent>
</Card>
</div>
</div>
</div>
);
}

TypeScript Types

All tokens are exported with TypeScript types:

import type {
ColorToken,
SpacingToken,
RadiusToken,
BreakpointToken,
} from "@cpod/tokens";

// Use in your types
type CustomTheme = {
primary: ColorToken;
spacing: SpacingToken;
radius: RadiusToken;
};

Best Practices

1. Use Semantic Colors

// ✅ Good - Uses semantic color for status
<Badge variant="success">Active</Badge>
<Badge variant="destructive">Error</Badge>

// ❌ Avoid hardcoded colors
<Badge style={{ background: "#00ff00" }}>Active</Badge>

2. Consistent Spacing

// ✅ Good - Uses spacing scale
<div className="p-4 space-y-3">...</div>

// ❌ Avoid arbitrary values
<div className="p-[17px]">...</div>

3. Responsive Typography

// ✅ Good - Scales with breakpoints
<h1 className="text-2xl md:text-3xl lg:text-4xl">Title</h1>

// ❌ Missing responsive scaling
<h1 className="text-4xl">Title</h1>

4. Dark Mode Support

Always test in both themes:

// ✅ Good - Uses theme-aware colors
<div className="bg-card text-card-foreground">...</div>

// ❌ Fixed color (breaks dark mode)
<div className="bg-white text-black">...</div>

Reference