@trading-game/design-system
v0.1.7
Published
Trading Game Design System — shadcn/ui components with Tailwind CSS v4
Readme
Trading Game Design System
A component library and design token system for the Trading Game product. Built on shadcn/ui with a custom Figma-driven token architecture, Tailwind CSS v4, and React 19.
Published as @trading-game/design-system on npm.
Quick Start
Installation
npm install @trading-game/design-system@latest --safe-chain-skip-minimum-package-ageNote: The
--safe-chain-skip-minimum-package-ageflag bypasses npm's 72-hour safe-chain hold on newly published packages. Required when the latest version was published less than 72 hours ago (common for AI agents and CI pipelines).
1. Add the CSS imports
In your main CSS file (e.g. globals.css), add these three lines in this order:
@import "@trading-game/design-system/styles";
@import "tailwindcss";
@source "../node_modules/@trading-game/design-system/dist";Why
@source? Tailwind v4 skipsnode_modulesby default. Without this line, Tailwind won't generate CSS for the component classes. Adjust the path if your CSS file is not one level belownode_modules(e.g. in a monorepo use../../node_modules/...).
1b. Vite projects — add the Tailwind plugin
If your project uses Vite (e.g. Vite + React), you must add the Tailwind CSS plugin to your Vite config:
npm install @tailwindcss/vite// vite.config.js
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default {
plugins: [react(), tailwindcss()],
}Next.js projects do not need this — Next.js uses PostCSS for Tailwind automatically.
2. Add class="dark" to your <html> tag
The design system defaults to dark mode. Your root layout must include this:
<html class="dark">Without this class, components will render without the dark theme applied.
3. Fonts (handled automatically)
The styles import loads Barlow (body) and Orbitron (display/headings) from Google Fonts automatically. No additional font setup is needed.
Use font-body for Barlow and font-display for Orbitron in your Tailwind classes.
4. Use components
import { Button, Card, Badge } from "@trading-game/design-system"
export default function App() {
return (
<Card>
<Button variant="primary">Trade Now</Button>
<Badge>Live</Badge>
</Card>
)
}Peer dependencies
Make sure these are installed in your project:
npm install react react-dom tailwindcssRequires React 18+ and Tailwind CSS v4+.
What's inside
- 53 UI components — buttons, forms, dialogs, charts, sidebars, and more
- Design tokens — CSS custom properties for color, radius, and typography synced from Figma
- Typography classes — heading scale (h1–xs) and body scale (lg–xs) ready to use
- Dark mode — dark theme by default, light mode via
class="light" - TypeScript — full type definitions included
- ESM + CJS — works with any bundler
Available components
| Component | Import |
|---|---|
| Accordion | Accordion, AccordionItem, AccordionTrigger, AccordionContent |
| Alert | Alert, AlertTitle, AlertDescription |
| Alert Dialog | AlertDialog, AlertDialogTrigger, AlertDialogContent, ... |
| Avatar | Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup |
| Badge | Badge, badgeVariants |
| Breadcrumb | Breadcrumb, BreadcrumbList, BreadcrumbItem, ... |
| Button | Button, buttonVariants |
| Calendar | Calendar, CalendarDayButton |
| Card | Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter |
| Carousel | Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext |
| Chart | ChartContainer, ChartTooltip, ChartLegend, ChartStyle |
| Checkbox | Checkbox |
| Collapsible | Collapsible, CollapsibleTrigger, CollapsibleContent |
| Combobox | Combobox, ComboboxInput, ComboboxContent, ComboboxItem, ... |
| Command | Command, CommandDialog, CommandInput, CommandList, ... |
| Context Menu | ContextMenu, ContextMenuTrigger, ContextMenuContent, ... |
| Dialog | Dialog, DialogTrigger, DialogContent, DialogHeader, ... |
| Drawer | Drawer, DrawerTrigger, DrawerContent, DrawerHeader, ... |
| Dropdown Menu | DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, ... |
| Empty State | Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent |
| Field | Field, FieldLabel, FieldDescription, FieldError, FieldGroup |
| Form | Form, FormItem, FormLabel, FormControl, FormField, FormMessage |
| Hover Card | HoverCard, HoverCardTrigger, HoverCardContent |
| Input | Input |
| Input Group | InputGroup, InputGroupAddon, InputGroupButton, InputGroupText |
| Input OTP | InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator |
| Item | Item, ItemMedia, ItemContent, ItemTitle, ItemDescription |
| Kbd | Kbd, KbdGroup |
| Label | Label |
| Menubar | Menubar, MenubarMenu, MenubarTrigger, MenubarContent, ... |
| Native Select | NativeSelect, NativeSelectOptGroup, NativeSelectOption |
| Navigation Menu | NavigationMenu, NavigationMenuList, NavigationMenuTrigger, ... |
| Pagination | Pagination, PaginationContent, PaginationLink, ... |
| Popover | Popover, PopoverTrigger, PopoverContent, PopoverAnchor |
| Progress | Progress |
| Radio Group | RadioGroup, RadioGroupItem |
| Resizable | ResizableHandle, ResizablePanel, ResizablePanelGroup |
| Scroll Area | ScrollArea, ScrollBar |
| Select | Select, SelectTrigger, SelectContent, SelectItem, ... |
| Separator | Separator |
| Sheet | Sheet, SheetTrigger, SheetContent, SheetHeader, ... |
| Sidebar | Sidebar, SidebarProvider, SidebarMenu, SidebarMenuItem, ... |
| Skeleton | Skeleton |
| Slider | Slider |
| Spinner | Spinner |
| Switch | Switch |
| Table | Table, TableHeader, TableBody, TableRow, TableHead, TableCell |
| Tabs | Tabs, TabsList, TabsTrigger, TabsContent |
| Textarea | Textarea |
| Toast | Toaster |
| Toggle | Toggle, toggleVariants |
| Toggle Group | ToggleGroup, ToggleGroupItem |
| Tooltip | Tooltip, TooltipTrigger, TooltipContent, TooltipProvider |
Button variants and sizes
// Cyan family
<Button variant="primary" /> // cyan filled — main CTA
<Button variant="secondary" /> // cyan outline — secondary action
<Button variant="tertiary" /> // cyan text — minimal
// Sizes
<Button size="lg" /> // 48px height (default)
<Button size="md" /> // 40px height
<Button size="sm" /> // 32px height
<Button size="xs" /> // 24px height
<Button size="icon-lg" /> // 48px square
<Button size="icon-md" /> // 40px square
<Button size="icon-sm" /> // 28px square
<Button size="icon-xs" /> // 24px squareBadge variants
// Default (solid) — 5 colors
<Badge /> // cyan (default)
<Badge variant="default-amber" /> // amber
<Badge variant="default-purple" /> // purple
<Badge variant="default-success" /> // green
<Badge variant="default-fail" /> // red
// Fill (tint) — 5 colors
<Badge variant="fill" /> // cyan tint
<Badge variant="fill-amber" /> // amber tint
<Badge variant="fill-purple" /> // purple tint
<Badge variant="fill-success" /> // green tint
<Badge variant="fill-fail" /> // red tint
// Ghost (transparent) — 5 colors
<Badge variant="ghost" /> // cyan text
<Badge variant="ghost-amber" /> // amber text
<Badge variant="ghost-purple" /> // purple text
<Badge variant="ghost-success" /> // green text
<Badge variant="ghost-fail" /> // red text
// Sizes (8pt grid)
<Badge size="sm" /> // 24px height
<Badge size="md" /> // 32px height (default)
<Badge size="lg" /> // 40px heightAlert variants
<Alert variant="info" /> // blue — informational (default)
<Alert variant="error" /> // red — error stateDesign tokens
All tokens are CSS custom properties, loaded automatically via @trading-game/design-system/styles.
Color tokens
| Token class | CSS variable | Value | Usage |
|---|---|---|---|
| bg-background | --background | #020B0A | Page background |
| bg-card | --card | #06000F | Card/panel background |
| bg-popover | --popover | #0A1A1E | Elevated surfaces |
| bg-muted | --muted | #0A1A1E | Muted surfaces |
| bg-primary | --primary | #00FFFF | Brand cyan — CTAs |
| bg-primary-hover | --primary-hover | #00D4D4 | Cyan hover state |
| bg-secondary | --secondary | #FFB800 @ 4% | Amber tint background |
| bg-secondary-hover | --secondary-hover | #FFB800 | Amber full |
| bg-hover | --hover | cyan @ 12% | Interactive hover background |
| bg-overlay | --overlay | black @ 50% | Modal/dialog backdrop |
| bg-destructive | --destructive | #FF3355 | Destructive actions |
| bg-brand-accent | --brand-accent | #FF6600 | Accent orange |
| bg-brand-accent-hover | --brand-accent-hover | #D45200 | Accent orange hover |
Text tokens
| Token class | Value | Usage |
|---|---|---|
| text-on-prominent | #D5EEE8 | Primary text |
| text-on-subtle | #7AA8AE | Paragraphs, descriptions, labels |
| text-on-muted | #295B60 | Low-emphasis text |
| text-on-decorative | #101E25 | Decorative/dark-on-dark text |
| text-primary-foreground | #020B0A | Text on primary backgrounds |
| text-semantic-win | #00FF9F | Positive/profit |
| text-semantic-loss | #FF3355 | Negative/loss |
| text-semantic-warning | #FF8C00 | Warning state |
Border & focus tokens
| Token class | Value | Usage |
|---|---|---|
| border-border | #0F2830 | Default borders/dividers |
| ring-ring | #00FFFF | Focus ring |
| border-input | #0F2830 | Input borders |
Other tokens
| Token class | Value | Usage |
|---|---|---|
| bg-accent | #0A1A1E | UI interaction surface |
| bg-accent-hover | darker | Accent hover |
| bg-badge-rank | #A040FF | Violet — badge/rank accent |
| bg-slider-range | cyan @ 40% | Slider/switch filled range |
| bg-overlay | black @ 50% | Modal/dialog backdrop |
| rounded-lg | 0.625rem | Base border radius |
Using opacity with tokens
Opacity on tokens is allowed and encouraged:
✅ bg-primary/20 → cyan at 20% opacity
✅ border-border/50 → border at 50% opacity
✅ ring-primary/10 → ring at 10% opacity
❌ bg-black/50 → NOT a token, use bg-overlay insteadTypography
The styles export includes pre-built typography classes:
Heading scale (Orbitron · Semibold · tracking 1.5px · uppercase)
| Class | Size |
|---|---|
| heading-h1 | 72px |
| heading-h2 | 64px |
| heading-h3 | 48px |
| heading-h4 | 40px |
| heading-xs | 24px |
Body scale (Barlow · Semibold)
| Class | Size / Line height |
|---|---|
| body-lg | 18px / 28px |
| body-md | 16px / 24px |
| body-sm | 12px / 16px |
| body-xs | 8px / 12px |
Font utilities
| Tailwind class | Font |
|---|---|
| font-display | Orbitron — headings, display text |
| font-body or font-sans | Barlow — body text (default) |
AI Agent Setup
Cursor
Copy the included rule file into your project:
mkdir -p .cursor/rules
cp node_modules/@trading-game/design-system/rules/design-system-consuming-project.mdc .cursor/rules/Claude Code
Add the following to your project's CLAUDE.md:
## Design System
This project uses @trading-game/design-system. Before writing any UI:
1. Check if the component exists in the package — import it, don't re-implement
2. Use only design token classes (bg-background, text-on-prominent, etc.) — no hardcoded hex or raw Tailwind palette colors
3. Do not install lucide-react, tailwindcss, or other bundled dependencies separately
4. If no token exists for a value, ask before using a hardcoded value
See node_modules/@trading-game/design-system/rules/design-system-consuming-project.mdc for full rules.
See node_modules/@trading-game/design-system/README.md for complete token and component reference.What the rules enforce
- Check the package first before writing any custom UI element
- Use only design token classes — no hardcoded hex, no raw Tailwind palette colors, no raw
var()wrappers likebg-[var(--token)] - Don't re-install bundled dependencies (lucide-react, tailwindcss, etc.)
- Ask before proceeding if no token exists for a value needed
Common mistakes
| Wrong | Right | Why |
|---|---|---|
| bg-gray-900 | bg-background | Raw Tailwind palette — use tokens |
| text-white | text-on-prominent | Not a semantic token |
| bg-black/50 | bg-overlay | Overlay has its own token |
| bg-[#00FFFF] | bg-primary | Hardcoded hex — use token |
| bg-[var(--primary)] | bg-primary | Raw CSS var — Tailwind v4 maps tokens directly |
| hsl(var(--primary)) | bg-primary | Tailwind v3 syntax — not needed in v4 |
| Installing lucide-react | Already bundled | Icons are included in the package |
Do NOT install separately
These are bundled with the package. Installing them separately can cause version conflicts:
lucide-react— icon libraryradix-ui— headless primitivesclass-variance-authority— variant APIcmdk— command palettevaul— drawersonner— toastrecharts— chartsreact-day-picker— calendarembla-carousel-react— carouselreact-resizable-panels— resizable panels
Further reading
- trading-game-ds-guide.md — comprehensive AI-readable guide with all 876 Figma tokens, full component catalogue, and detailed usage rules
Development (contributors only)
# Clone
git clone https://github.com/trading-game/trading-game-design-system.git
cd trading-game-design-system
# Install dependencies
npm install
# Start dev server (Next.js component playground)
npm run dev
# Build the library (ESM + CJS + types)
npm run build
# Build the Next.js showcase app
npm run build:nextUpdating design tokens
Design tokens are managed in Figma and exported as JSON variables. To update:
- Export updated variables from Figma (TailwindCSS.json, Theme.json, Mode.json)
- Update the CSS custom properties in
app/globals.cssandsrc/styles.css
Tech stack
- React 19 + TypeScript
- Tailwind CSS v4 — CSS-first configuration
- shadcn/ui (New York style) — base component primitives
- Radix UI — accessible headless primitives
- Figma — source of truth for design tokens
