Skip to content

Conversation

@kylecarbs
Copy link
Member

Problem

The codebase had 157 instances of hardcoded hex colors scattered throughout using confusing Tailwind syntax like text-[#808080], bg-[#1e1e1e], and border-[rgba(244,67,54,0.1)]. This makes the color scheme difficult to maintain and update consistently.

Solution

Centralized all colors as semantic CSS variables in src/styles/globals.css using Tailwind v4's @theme directive. These automatically generate corresponding Tailwind utility classes.

Color categories added (40+ new variables):

  • Text variants: text-muted-light, text-placeholder, text-bright, text-label, etc.
  • Border variants: border-medium, border-darker, border-light, border-subtle, etc.
  • Background variants: bg-dark, bg-darker, bg-modal-bg, bg-code-bg, etc.
  • Accent variants: bg-accent-hover, bg-accent-dark, text-accent-light, etc.
  • Status colors: text-danger-light, text-danger-soft, text-warning, text-success-light
  • Toast backgrounds: bg-toast-success-bg, bg-toast-error-bg, with proper opacity
  • Semi-transparent overlays: bg-danger-overlay, bg-warning-overlay, bg-white-overlay
  • Code highlighting: text-code-type, text-code-keyword, bg-code-keyword-overlay
  • Review/diff backgrounds: bg-review-bg-blue, bg-review-bg-info, bg-review-bg-warning

Examples of replacements:

- className="text-[#808080]"
+ className="text-text-muted-light"

- className="bg-[#0e639c] hover:bg-[#1177bb]"
+ className="bg-accent-dark hover:bg-accent-hover"

- className="bg-[rgba(244,67,54,0.1)] border-[#f44336]"
+ className="bg-danger-overlay border-danger"

- className="bg-[var(--color-code-bg)]"
+ className="bg-code-bg"

Impact

  • ✅ All 157 hardcoded color instances replaced
  • ✅ Consistent naming convention across the codebase
  • ✅ Easier to update color scheme globally
  • ✅ Type checking passes
  • ✅ Better readability: text-text-muted-light is clearer than text-[#808080]

Testing

  • make typecheck passes
  • make fmt applied
  • All existing colors mapped to semantic equivalents with matching HSL values

Generated with cmux

Replace hardcoded hex colors and arbitrary Tailwind values with semantic
CSS variables throughout the codebase. This improves maintainability and
makes it easier to update the color scheme consistently.

Changes:
- Extended @theme in globals.css with 40+ new semantic color variables
- Replaced 157 instances of text-[#...], bg-[#...], border-[#...]
- Replaced rgba() arbitrary values with named color variables
- Replaced var() usages with direct Tailwind classes
- Applied to both components and Storybook stories

New color categories added:
- Text variants (muted-light, muted-dark, placeholder, subtle, etc.)
- Border variants (border-medium, border-darker, border-light, etc.)
- Background variants (bg-dark, bg-darker, modal-bg, etc.)
- Accent variants (accent-hover, accent-dark, accent-light, etc.)
- Status colors (danger-light, danger-soft, warning, success-light, etc.)
- Toast/notification backgrounds with opacity
- Semi-transparent overlays (danger-overlay, warning-overlay, etc.)
- Code syntax highlighting (code-type, code-keyword, etc.)
- Review/diff backgrounds (review-bg-blue, review-bg-info, etc.)

All colors are now centralized in src/styles/globals.css and use
Tailwind v4's @theme directive for automatic class generation.

_Generated with `cmux`_
@kylecarbs kylecarbs force-pushed the centralize-tailwind-colors branch from 34b3d24 to 7a7a84b Compare October 23, 2025 03:18
Fixed border-b-bg-dark -> border-b border-dark and similar patterns.
Tailwind requires directional border utilities (border-b, border-t, etc.)
to have color specified as a separate class, not concatenated.
The StatusIndicator was using bg-text-muted-dark which is invalid.
Should be bg-muted-dark to use the muted-dark color as a background.
@kylecarbs kylecarbs merged commit 099aa26 into main Oct 23, 2025
13 checks passed
@kylecarbs kylecarbs deleted the centralize-tailwind-colors branch October 23, 2025 03:32
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.

1 participant