Skip to content

Add pui-theme-radix: Radix Themes-based design system for PUI#62

Draft
developit wants to merge 9 commits intomainfrom
claude/implement-radix-themes-Fi0jT
Draft

Add pui-theme-radix: Radix Themes-based design system for PUI#62
developit wants to merge 9 commits intomainfrom
claude/implement-radix-themes-Fi0jT

Conversation

@developit
Copy link
Copy Markdown
Owner

Summary

This PR introduces pui-theme-radix, a new theme package that brings Radix Themes design tokens and component styles to PUI. It provides a complete, production-ready theme built on Radix's carefully crafted color system and component patterns.

Key Changes

  • New package: packages/pui-theme-radix/ with full build pipeline
  • Token generation: Automated gen-tokens.mjs script that:
    • Reads @radix-ui/colors CSS files
    • Resolves Radix Themes token variables (accent, gray, semantic colors)
    • Converts colors to HSL triplets for PUI's --p-* custom properties
    • Generates light/dark theme variants with prefers-color-scheme support
  • Component ports: CSS implementations for:
    • Button: All 6 variants (solid, destructive, outline, secondary, ghost, soft, surface, link) with sizes 1-4 and icon support
    • Input: Surface and soft variants with sizes 1-4, focus/invalid/disabled states
    • Dialog: Content, backdrop, and popover styles with smooth animations
  • Build system: PostCSS pipeline with postcss-import and postcss-nesting for modular CSS
  • Configuration:
    • token-map.json defines Radix → PUI token mappings
    • Defaults: blue accent, slate gray, solid panel background
    • Extensible for custom accent/gray colors

Implementation Details

  • Color parsing: Handles hex (#RGB, #RRGGBB, #RRGGBBAA) and rgba() formats from Radix sources
  • Alpha compositing: Transparent colors are composited over the background before HSL conversion
  • P3 color filtering: Strips @supports (color: color(display-p3)) blocks to ensure sRGB consistency
  • Variable resolution: Recursive var() reference resolution with cycle detection
  • Scope-aware extraction: Separate light/dark token generation with proper selector matching
  • Radix compatibility: Selector mapping from Radix's .rt-* classes to PUI's [p="*"] attributes
  • State handling: Disabled, loading, focus-visible, and open states with appropriate visual feedback

Files Added

  • package.json with build scripts and dependencies
  • postcss.config.cjs for CSS processing
  • src/build/gen-tokens.mjs (419 lines) - token generation engine
  • src/build/token-map.json - token mapping configuration
  • src/components/button.css, input.css, dialog.css - component styles
  • src/generated/tokens.css - generated theme tokens (light + dark)
  • src/index.css - main entry point
  • Vendored Radix Themes source files (tokens, colors, breakpoints)

Usage

npm install pui-theme-radix
@import "pui-theme-radix";

The theme automatically provides light/dark variants via prefers-color-scheme and .dark class selector.

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy

… ports

Implements a complete Radix Themes-based theme for PUI:

- Token pipeline: gen-tokens.mjs reads @radix-ui/colors + vendored Radix
  token CSS, resolves variables for configured accent (blue) / gray (slate),
  converts to HSL triplets, and emits src/generated/tokens.css
- token-map.json: explicit mapping of 27 PUI --p-* tokens to Radix vars
- Vendored Radix sources: tokens (all color scales, semantic colors, focus,
  typography, radius, shadow, spacing) and component CSS (button, text-field,
  text-area, dialog + _internal bases)
- Component ports: button (solid/outline/ghost/soft/surface/destructive/link
  variants, 4 sizes + aliases, open/disabled/loading states), input (surface/
  soft variants, 4 sizes, focus/invalid/disabled), dialog (content + backdrop
  + popover + dropdown surfaces with Radix shadows and animations)
- Build: PostCSS with postcss-import + postcss-nesting, pnpm scripts for
  build:tokens and build:css
- Light + dark mode via :root, @media prefers-color-scheme, and .dark class

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 8, 2026

Deploy Preview for pui-demo ready!

Name Link
🔨 Latest commit 023aad4
🔍 Latest deploy log https://app.netlify.com/projects/pui-demo/deploys/69928f6d83b53200089e084e
😎 Deploy Preview https://deploy-preview-62--pui-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 8, 2026

Size Change: 0 B

Total Size: 11.3 kB

ℹ️ View Unchanged
Filename Size
dist/index.css 6.22 kB
dist/index.js 5.06 kB

compressed-size-action

claude and others added 8 commits February 8, 2026 18:53
- ThemeToggle component dynamically injects/removes Radix theme CSS
  as a <link> element, persists choice in localStorage
- Toggle button added to nav bar with pill-style styling
- Vite alias added for pui-theme-radix package, CSS imported as ?url
  so it becomes a separate asset loaded on demand

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
Previously only button, input, and dialog were ported, making the theme
look nearly identical to PUI's default (just bluer). This adds Radix-style
overrides for all remaining components:

- Menu items: accent-colored hover highlights (not gray)
- Card: borderless with subtle Radix shadow
- Tabs: underline indicator instead of pill/shadow
- Badge: pill-shaped (full border-radius)
- Alert: accent left-border indicator (callout style)
- Table: clean borderless with divider lines
- Form controls (checkbox, radio, switch, slider, select, textarea):
  accent-colored active states, outline-based focus
- Toggle/toggle-group: ghost-style with accent highlight
- Progress: rounded pill with accent fill
- Tooltip: dark solid with shadow
- Avatar: accent-tinted fallback
- Accordion: clean dividers, accent hover
- Hover card: Radix surface shadows
- Sheet/drawer: refined shadows and border-radius
- Navigation/menubar/sidebar: accent-colored hover/active states
- Skeleton: pulse animation instead of shimmer
- Separator/label: subtle refinements

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
- Slider: revert override — PUI's original already matches Radix
- Menus: match Radix base-menu.css size-2 values (8px container
  padding, 32px item height, 12px item padding, 4px item radius,
  8px container radius, shadow-5 with 1px ring). Inset separators
  inside menus with proper margins.
- Tabs: full-width tablist with inset box-shadow bottom border,
  2.5rem tab height, hover gray pill effect, accent-colored
  underline indicator via ::after, flex-start justify

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
Menu padding fix:
- Changed from 0.5rem (8px) to 0.25rem (4px) vertical padding
- This matches Radix size-2 spacing and fixes "2x too large" issue
- Now applies properly to both dropdown-content and context-menu

Theme customizer:
- Added ThemeCustomizer component to demo nav
- Users can paste custom CSS from Radix Themes Playground
- CSS is injected via <style> tag and persisted to localStorage
- Built entirely with PUI components (Dialog, Button, Label, Textarea)
- Includes link to https://www.radix-ui.com/themes/playground
- Apply/Clear/Cancel actions with toast notifications

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
PUI's Dialog uses commandfor/command attributes for native dialog
control. Replaced open/onOpenChange state management with proper
Dialog.Trigger and Dialog.Close wrappers. Switched from controlled
textarea state to ref-based access.

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
Rewrites theme-customizer to support:
- Visual color swatch grids for all 25 Radix accent colors and 6 gray scales
- Button groups for radius (none/small/medium/large/full) and scaling (90-110%)
- Paste input that parses Radix Playground <Theme> JSX output
- Runtime CSS generation mapping Radix settings to --p-* custom properties
- Hex-to-HSL conversion for all color steps
- localStorage persistence of theme settings

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
Updates:
- Add dark color scales to ACCENT_COLORS and GRAY_COLORS lookup tables
- Restructure color data to include both light and dark step values
- Update generateCSS to output three CSS blocks:
  1. :root with light mode values
  2. @media (prefers-color-scheme: dark) for automatic dark mode
  3. .dark class for explicit dark mode
- Update Swatch components to use light.step9/step11
- This fixes automatic dark mode support when using custom Radix themes

https://claude.ai/code/session_014nSucTSwQuGmUfrfoBM5Zy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants