11module Theme
22 class CSS
3- def self . retrieve ( theme , with_directive : true , format : :css )
3+ # Ruby UI specific variables that are not part of the standard shadcn theme
4+ RUBY_UI_SPECIFIC_VARS = %w[ warning warning-foreground success success-foreground ] . freeze
5+
6+ def self . retrieve ( theme , with_directive : true , format : :css , exclude_ruby_ui_vars : false )
47 theme_hash = send ( theme )
8+ theme_hash = filter_ruby_ui_vars ( theme_hash ) if exclude_ruby_ui_vars
59
610 case format
711 when :css
@@ -14,6 +18,12 @@ def self.retrieve(theme, with_directive: true, format: :css)
1418 end
1519 end
1620
21+ def self . filter_ruby_ui_vars ( theme_hash )
22+ theme_hash . transform_values do |properties |
23+ properties . reject { |key , _ | RUBY_UI_SPECIFIC_VARS . include? ( key . to_s ) }
24+ end
25+ end
26+
1727 def self . all_themes
1828 {
1929 default : default ,
@@ -86,23 +96,23 @@ def self.neutral
8696 dark : {
8797 background : "oklch(0.145 0 0)" ,
8898 foreground : "oklch(0.985 0 0)" ,
89- card : "oklch(0.145 0 0)" ,
99+ card : "oklch(0.205 0 0)" ,
90100 "card-foreground" : "oklch(0.985 0 0)" ,
91- popover : "oklch(0.145 0 0)" ,
101+ popover : "oklch(0.205 0 0)" ,
92102 "popover-foreground" : "oklch(0.985 0 0)" ,
93- primary : "oklch(0.985 0 0)" ,
103+ primary : "oklch(0.922 0 0)" ,
94104 "primary-foreground" : "oklch(0.205 0 0)" ,
95105 secondary : "oklch(0.269 0 0)" ,
96106 "secondary-foreground" : "oklch(0.985 0 0)" ,
97107 muted : "oklch(0.269 0 0)" ,
98108 "muted-foreground" : "oklch(0.708 0 0)" ,
99109 accent : "oklch(0.269 0 0)" ,
100110 "accent-foreground" : "oklch(0.985 0 0)" ,
101- destructive : "oklch(0.396 0.141 25.723 )" ,
111+ destructive : "oklch(0.704 0.191 22.216 )" ,
102112 "destructive-foreground" : "oklch(0.637 0.237 25.331)" ,
103- border : "oklch(0.269 0 0)" ,
104- input : "oklch(0.269 0 0)" ,
105- ring : "oklch(0.439 0 0)" ,
113+ border : "oklch(1 0 0 / 10% )" ,
114+ input : "oklch(1 0 0 / 15% )" ,
115+ ring : "oklch(0.556 0 0)" ,
106116 "chart-1" : "oklch(0.488 0.243 264.376)" ,
107117 "chart-2" : "oklch(0.696 0.17 162.48)" ,
108118 "chart-3" : "oklch(0.769 0.188 70.08)" ,
@@ -114,8 +124,8 @@ def self.neutral
114124 "sidebar-primary-foreground" : "oklch(0.985 0 0)" ,
115125 "sidebar-accent" : "oklch(0.269 0 0)" ,
116126 "sidebar-accent-foreground" : "oklch(0.985 0 0)" ,
117- "sidebar-border" : "oklch(0.269 0 0)" ,
118- "sidebar-ring" : "oklch(0.439 0 0)" ,
127+ "sidebar-border" : "oklch(1 0 0 / 10% )" ,
128+ "sidebar-ring" : "oklch(0.556 0 0)" ,
119129 warning : "hsl(38 92% 50%)" ,
120130 "warning-foreground" : "hsl(0 0% 100%)" ,
121131 success : "hsl(84 81% 44%)" ,
@@ -457,23 +467,23 @@ def self.default_dark
457467 {
458468 background : "oklch(0.145 0 0)" ,
459469 foreground : "oklch(0.985 0 0)" ,
460- card : "oklch(0.145 0 0)" ,
470+ card : "oklch(0.205 0 0)" ,
461471 "card-foreground" : "oklch(0.985 0 0)" ,
462- popover : "oklch(0.145 0 0)" ,
472+ popover : "oklch(0.205 0 0)" ,
463473 "popover-foreground" : "oklch(0.985 0 0)" ,
464- primary : "oklch(0.985 0 0)" ,
474+ primary : "oklch(0.922 0 0)" ,
465475 "primary-foreground" : "oklch(0.205 0 0)" ,
466476 secondary : "oklch(0.269 0 0)" ,
467477 "secondary-foreground" : "oklch(0.985 0 0)" ,
468478 muted : "oklch(0.269 0 0)" ,
469479 "muted-foreground" : "oklch(0.708 0 0)" ,
470480 accent : "oklch(0.269 0 0)" ,
471481 "accent-foreground" : "oklch(0.985 0 0)" ,
472- destructive : "oklch(0.396 0.141 25.723 )" ,
482+ destructive : "oklch(0.704 0.191 22.216 )" ,
473483 "destructive-foreground" : "oklch(0.637 0.237 25.331)" ,
474- border : "oklch(0.269 0 0)" ,
475- input : "oklch(0.269 0 0)" ,
476- ring : "oklch(0.439 0 0)" ,
484+ border : "oklch(1 0 0 / 10% )" ,
485+ input : "oklch(1 0 0 / 15% )" ,
486+ ring : "oklch(0.556 0 0)" ,
477487 "chart-1" : "oklch(0.488 0.243 264.376)" ,
478488 "chart-2" : "oklch(0.696 0.17 162.48)" ,
479489 "chart-3" : "oklch(0.769 0.188 70.08)" ,
@@ -485,8 +495,8 @@ def self.default_dark
485495 "sidebar-primary-foreground" : "oklch(0.985 0 0)" ,
486496 "sidebar-accent" : "oklch(0.269 0 0)" ,
487497 "sidebar-accent-foreground" : "oklch(0.985 0 0)" ,
488- "sidebar-border" : "oklch(0.269 0 0)" ,
489- "sidebar-ring" : "oklch(0.439 0 0)" ,
498+ "sidebar-border" : "oklch(1 0 0 / 10% )" ,
499+ "sidebar-ring" : "oklch(0.556 0 0)" ,
490500 warning : "hsl(38 92% 50%)" ,
491501 "warning-foreground" : "hsl(0 0% 100%)" ,
492502 success : "hsl(84 81% 44%)" ,
@@ -510,11 +520,9 @@ def self.format_selector(selector)
510520 end
511521
512522 def self . wrap_with_directive ( css )
513- <<~CSS
514- @layer base {
515- #{ css }
516- }
517- CSS
523+ # Tailwind 4: :root and .dark selectors should NOT be wrapped in @layer base
524+ # This ensures CSS variables are properly accessible to @theme inline
525+ css
518526 end
519527 end
520528end
0 commit comments