--- name: theme-system description: Use when creating or modifying UI components, styling, or visual elements in OpenChamber. All UI colors must use theme tokens - never hardcoded values or Tailwind color classes. license: MIT compatibility: opencode --- ## Overview OpenChamber uses a JSON-based theme system. Themes are defined in `packages/ui/src/lib/theme/themes/`. Users can also add custom themes via `~/.config/openchamber/themes/`. **Core principle:** UI colors must use theme tokens - never hardcoded hex colors or Tailwind color classes. ## When to Use - Creating or modifying UI components - Working with colors, backgrounds, borders, or text ## Quick Decision Tree 1. **Code display?** → `syntax.*` 2. **Feedback/status?** → `status.*` 3. **Primary CTA?** → `primary.*` 4. **Interactive/clickable?** → `interactive.*` 5. **Background layer?** → `surface.*` 6. **Text?** → `surface.foreground` or `surface.mutedForeground` ## Critical Rules - `surface.elevated` = inputs, cards, panels - `interactive.hover` = **ONLY on clickable elements** - `interactive.selection` = active/selected states (not primary!) - Status colors = **ONLY for actual feedback** (errors, warnings, success) - Input footers = `bg-transparent` on elevated background ## Button Rules (MANDATORY) Use only the shared `Button` component from `packages/ui/src/components/ui/button.tsx`. - Do not create wrapper button components (for example `ButtonLarge`, `ButtonSmall`). - Do not hardcode button height/padding classes when a `size` variant exists. - Use semantic button variants consistently; avoid ad-hoc one-off button styling. ### Allowed Button Variants | Variant | Use for | Token direction | |-------|-------|-------| | `default` | Primary action in a local section/dialog | `primary.*` | | `outline` | Secondary visible action | `surface.elevated` + `interactive.*` | | `secondary` | Soft secondary action | `interactive.hover` / `interactive.active` | | `ghost` | Low-emphasis row/toolbar action | transparent + `interactive.hover` | | `destructive` | Destructive actions (`Delete`, `Revert all`) | `status.error*` | | `link` | Rare inline text action only | text-link style | ### Allowed Button Sizes | Size | Use for | |------|---------| | `xs` | Dense controls in rows/lists | | `sm` | Default compact action buttons | | `default` | Standard form/page actions | | `lg` | Prominent large actions | | `icon` | Icon-only square button | ### Button Selection Quick Guide 1. Main CTA in section/dialog -> `default` 2. Side action next to CTA -> `outline` 3. Quiet auxiliary action -> `ghost` 4. Dangerous action -> `destructive` 5. Tiny row action -> keep same variant, set `size="xs"` ### Never Use - Hardcoded hex colors (`#FF0000`) - Tailwind colors (`bg-white`, `text-blue-500`, `bg-gray-*`) - Deprecated: `bg-secondary`, `bg-muted` ## Usage ### Via Hook ```tsx import { useThemeSystem } from '@/contexts/useThemeSystem'; const { currentTheme } = useThemeSystem();