policyengine-tailwind-shadcn
Tailwind CSS v4 + shadcn/ui integration patterns for PolicyEngine frontend projects. Covers @theme namespaces, CSS variable conventions, SVG var() usage, and common mistakes. Triggers: "Tailwind v4", "@theme", "shadcn", "CSS variables", "design tokens CSS", "theme.css", "@theme inline"
What this skill does
# Tailwind CSS v4 + shadcn/ui integration
Technical reference for how PolicyEngine's CSS-first design token architecture works. This skill explains the **mechanism** — how Tailwind v4 and shadcn/ui consume CSS variables. For the actual **token values** (colors, fonts, spacing), see `policyengine-design-skill`.
## Architecture overview
PolicyEngine uses a single CSS file (`@policyengine/ui-kit/theme.css`) as the source of truth for all design tokens. This file has three layers:
```
Layer 1: :root { --primary: #2C7A7B; } ← Raw values (shadcn/ui convention)
Layer 2: @theme inline { --color-primary: var(--primary); } ← Bridge to Tailwind
Layer 3: @theme { --color-teal-500: #319795; } ← Brand palette + fonts + sizes
```
Consumers import it in their `globals.css`:
```css
@import "tailwindcss";
@import "@policyengine/ui-kit/theme.css";
```
## Tailwind v4 `@theme` namespaces
Tailwind v4 uses CSS custom properties in `@theme` blocks to generate utility classes. The **namespace prefix** determines which utilities are created:
| CSS variable prefix | Tailwind utility | Example variable | Example class |
|---|---|---|---|
| `--color-*` | `bg-*`, `text-*`, `border-*`, `fill-*` | `--color-primary: #2C7A7B` | `bg-primary`, `text-primary` |
| `--color-teal-*` | `bg-teal-*`, `text-teal-*` | `--color-teal-500: #319795` | `bg-teal-500` |
| `--text-*` | `text-*` (font size) | `--text-sm: 14px` | `text-sm` |
| `--font-*` | `font-*` | `--font-sans: Inter, ...` | `font-sans` |
| `--radius-*` | `rounded-*` | `--radius-lg: 8px` | `rounded-lg` |
| `--spacing-*` | `p-*`, `m-*`, `gap-*`, `w-*`, `h-*` | `--spacing-header: 58px` | `h-header` |
| `--breakpoint-*` | `sm:`, `md:`, `lg:` | `--breakpoint-md: 62rem` | `md:flex-col` |
**Source:** [Tailwind v4 Theme docs](https://tailwindcss.com/docs/theme)
## `@theme` vs `@theme inline`
```css
/* @theme — bakes values directly into generated CSS */
@theme {
--color-teal-500: #319795; /* Resolved at build time */
}
/* @theme inline — preserves var() for runtime resolution */
@theme inline {
--color-primary: var(--primary); /* Resolved at runtime via :root */
}
```
**When to use `@theme inline`:**
- When the value references a `:root` CSS variable (`var(--something)`)
- Required for dark mode (`:root` values change, Tailwind must re-resolve)
- Used for all shadcn/ui semantic tokens (primary, background, foreground, etc.)
**When to use `@theme`:**
- When the value is a static literal (`#319795`, `14px`, `Inter`)
- Used for brand palette colors, font sizes, spacing, breakpoints
**Source:** [Tailwind v4 Functions and Directives](https://tailwindcss.com/docs/functions-and-directives)
## shadcn/ui CSS variable convention
shadcn/ui defines semantic tokens as **unprefixed** CSS variables in `:root`:
```css
:root {
--primary: #2C7A7B;
--background: #FFFFFF;
--foreground: #000000;
--muted: #F2F4F7;
--muted-foreground: #6B7280;
--border: #E2E8F0;
--chart-1: #319795;
--chart-2: #0EA5E9;
/* ... */
}
```
These are then bridged to Tailwind via `@theme inline`:
```css
@theme inline {
--color-primary: var(--primary); /* → bg-primary, text-primary */
--color-background: var(--background); /* → bg-background */
--color-foreground: var(--foreground); /* → text-foreground */
--color-chart-1: var(--chart-1); /* → fill-chart-1 */
}
```
**Source:** [shadcn/ui Theming](https://ui.shadcn.com/docs/theming), [shadcn/ui Tailwind v4 guide](https://ui.shadcn.com/docs/tailwind-v4)
## SVG `var()` in Recharts
Modern browsers resolve CSS custom properties in SVG presentation attributes. Recharts `fill` and `stroke` props accept `var()` directly:
```tsx
<Bar fill="var(--chart-1)" />
<Line stroke="var(--chart-2)" />
<CartesianGrid stroke="var(--border)" />
```
No helper function needed. The old `getCssVar()` / `getComputedStyle()` pattern is unnecessary.
**Source:** [shadcn/ui Charts](https://ui.shadcn.com/docs/components/chart)
## Complete namespace reference
### Layer 1: `:root` (shadcn/ui semantic)
| Variable | Hex | Usage |
|----------|-----|-------|
| `--primary` | `#2C7A7B` | Primary actions, buttons |
| `--primary-foreground` | `#FFFFFF` | Text on primary |
| `--background` | `#FFFFFF` | Page background |
| `--foreground` | `#000000` | Body text |
| `--muted` | `#F2F4F7` | Muted backgrounds |
| `--muted-foreground` | `#6B7280` | Secondary text |
| `--border` | `#E2E8F0` | Borders, dividers |
| `--card` | `#FFFFFF` | Card backgrounds |
| `--destructive` | `#DC2626` | Error states (red-600, clears WCAG AA on the white `--destructive-foreground`) |
| `--ring` | `#319795` | Focus rings |
| `--chart-1` through `--chart-5` | Teal→Gray | Chart series |
### Layer 2: `@theme inline` (bridges)
Maps each `:root` var to Tailwind's `--color-*` namespace. Example:
- `--color-primary: var(--primary)` → enables `bg-primary`, `text-primary`
- `--color-chart-1: var(--chart-1)` → enables `fill-chart-1`
### Layer 3: `@theme` (brand palette)
| Namespace | Example | Tailwind class |
|-----------|---------|---------------|
| `--color-teal-*` | `--color-teal-500: #319795` | `bg-teal-500` |
| `--color-gray-*` | `--color-gray-600: #4B5563` | `text-gray-600` |
| `--color-blue-*` | `--color-blue-500: #0EA5E9` | `bg-blue-500` |
| `--text-*` | `--text-sm: 14px` | `text-sm` |
| `--font-*` | `--font-sans: Inter, ...` | `font-sans` |
| `--spacing-*` | `--spacing-header: 58px` | `h-header` |
## Common mistakes
### 1. Using `@theme` instead of `@theme inline` for var() references
```css
/* WRONG — var() won't resolve, Tailwind bakes the literal string */
@theme {
--color-primary: var(--primary);
}
/* CORRECT — var() resolves at runtime */
@theme inline {
--color-primary: var(--primary);
}
```
### 2. Wrong namespace prefix
```css
/* WRONG — creates a utility called "primary", not a color */
@theme {
--primary: #2C7A7B;
}
/* CORRECT — --color-* prefix creates bg-primary, text-primary */
@theme inline {
--color-primary: var(--primary);
}
```
### 3. Using getCssVar() for Recharts
```tsx
// WRONG — unnecessary helper
const color = getCssVar('--chart-1');
<Bar fill={color} />
// CORRECT — SVG accepts var() directly
<Bar fill="var(--chart-1)" />
```
### 4. Hardcoding hex in components
```tsx
// WRONG
<div style={{ color: '#319795' }}>
// CORRECT — use Tailwind class
<div className="text-teal-500">
// CORRECT — use CSS var for inline styles
<div style={{ color: 'var(--primary)' }}>
```
### 5. Creating tailwind.config.ts
Tailwind v4 does NOT use `tailwind.config.ts`. All configuration is in CSS via `@theme` blocks. The ui-kit theme CSS file handles this.
### 6. Using old pe-* prefixed classes
```tsx
// WRONG — old convention
<div className="bg-pe-primary-500 text-pe-text-secondary p-pe-lg">
// CORRECT — standard Tailwind/shadcn classes
<div className="bg-teal-500 text-muted-foreground p-4">
```
## Related skills
- `policyengine-design-skill` — Token values, color tables, chart branding
- `policyengine-frontend-builder-spec-skill` — Mandatory technology requirements
- `policyengine-recharts-skill` — Chart-specific patterns
- `policyengine-interactive-tools-skill` — Standalone tool scaffolding
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.