gpui_component/theme/theme_color.rs
1use std::sync::Arc;
2
3use crate::{theme::DEFAULT_THEME_COLORS, ThemeMode};
4
5use gpui::Hsla;
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9/// Theme colors used throughout the UI components.
10#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, JsonSchema)]
11pub struct ThemeColor {
12 /// Used for accents such as hover background on MenuItem, ListItem, etc.
13 pub accent: Hsla,
14 /// Used for accent text color.
15 pub accent_foreground: Hsla,
16 /// Accordion background color.
17 pub accordion: Hsla,
18 /// Accordion hover background color.
19 pub accordion_hover: Hsla,
20 /// Default background color.
21 pub background: Hsla,
22 /// Default border color
23 pub border: Hsla,
24 /// Background color for GroupBox.
25 pub group_box: Hsla,
26 /// Text color for GroupBox.
27 pub group_box_foreground: Hsla,
28 /// Input caret color (Blinking cursor).
29 pub caret: Hsla,
30 /// Chart 1 color.
31 pub chart_1: Hsla,
32 /// Chart 2 color.
33 pub chart_2: Hsla,
34 /// Chart 3 color.
35 pub chart_3: Hsla,
36 /// Chart 4 color.
37 pub chart_4: Hsla,
38 /// Chart 5 color.
39 pub chart_5: Hsla,
40 /// Danger background color.
41 pub danger: Hsla,
42 /// Danger active background color.
43 pub danger_active: Hsla,
44 /// Danger text color.
45 pub danger_foreground: Hsla,
46 /// Danger hover background color.
47 pub danger_hover: Hsla,
48 /// Description List label background color.
49 pub description_list_label: Hsla,
50 /// Description List label foreground color.
51 pub description_list_label_foreground: Hsla,
52 /// Drag border color.
53 pub drag_border: Hsla,
54 /// Drop target background color.
55 pub drop_target: Hsla,
56 /// Default text color.
57 pub foreground: Hsla,
58 /// Info background color.
59 pub info: Hsla,
60 /// Info active background color.
61 pub info_active: Hsla,
62 /// Info text color.
63 pub info_foreground: Hsla,
64 /// Info hover background color.
65 pub info_hover: Hsla,
66 /// Border color for inputs such as Input, Select, etc.
67 pub input: Hsla,
68 /// Link text color.
69 pub link: Hsla,
70 /// Active link text color.
71 pub link_active: Hsla,
72 /// Hover link text color.
73 pub link_hover: Hsla,
74 /// Background color for List and ListItem.
75 pub list: Hsla,
76 /// Background color for active ListItem.
77 pub list_active: Hsla,
78 /// Border color for active ListItem.
79 pub list_active_border: Hsla,
80 /// Stripe background color for even ListItem.
81 pub list_even: Hsla,
82 /// Background color for List header.
83 pub list_head: Hsla,
84 /// Hover background color for ListItem.
85 pub list_hover: Hsla,
86 /// Muted backgrounds such as Skeleton and Switch.
87 pub muted: Hsla,
88 /// Muted text color, as used in disabled text.
89 pub muted_foreground: Hsla,
90 /// Background color for Popover.
91 pub popover: Hsla,
92 /// Text color for Popover.
93 pub popover_foreground: Hsla,
94 /// Primary background color.
95 pub primary: Hsla,
96 /// Active primary background color.
97 pub primary_active: Hsla,
98 /// Primary text color.
99 pub primary_foreground: Hsla,
100 /// Hover primary background color.
101 pub primary_hover: Hsla,
102 /// Progress bar background color.
103 pub progress_bar: Hsla,
104 /// Used for focus ring.
105 pub ring: Hsla,
106 /// Scrollbar background color.
107 pub scrollbar: Hsla,
108 /// Scrollbar thumb background color.
109 pub scrollbar_thumb: Hsla,
110 /// Scrollbar thumb hover background color.
111 pub scrollbar_thumb_hover: Hsla,
112 /// Secondary background color.
113 pub secondary: Hsla,
114 /// Active secondary background color.
115 pub secondary_active: Hsla,
116 /// Secondary text color, used for secondary Button text color or secondary text.
117 pub secondary_foreground: Hsla,
118 /// Hover secondary background color.
119 pub secondary_hover: Hsla,
120 /// Input selection background color.
121 pub selection: Hsla,
122 /// Sidebar background color.
123 pub sidebar: Hsla,
124 /// Sidebar accent background color.
125 pub sidebar_accent: Hsla,
126 /// Sidebar accent text color.
127 pub sidebar_accent_foreground: Hsla,
128 /// Sidebar border color.
129 pub sidebar_border: Hsla,
130 /// Sidebar text color.
131 pub sidebar_foreground: Hsla,
132 /// Sidebar primary background color.
133 pub sidebar_primary: Hsla,
134 /// Sidebar primary text color.
135 pub sidebar_primary_foreground: Hsla,
136 /// Skeleton background color.
137 pub skeleton: Hsla,
138 /// Slider bar background color.
139 pub slider_bar: Hsla,
140 /// Slider thumb background color.
141 pub slider_thumb: Hsla,
142 /// Success background color.
143 pub success: Hsla,
144 /// Success text color.
145 pub success_foreground: Hsla,
146 /// Success hover background color.
147 pub success_hover: Hsla,
148 /// Success active background color.
149 pub success_active: Hsla,
150 /// Switch background color.
151 pub switch: Hsla,
152 /// Tab background color.
153 pub tab: Hsla,
154 /// Tab active background color.
155 pub tab_active: Hsla,
156 /// Tab active text color.
157 pub tab_active_foreground: Hsla,
158 /// TabBar background color.
159 pub tab_bar: Hsla,
160 /// TabBar segmented background color.
161 pub tab_bar_segmented: Hsla,
162 /// Tab text color.
163 pub tab_foreground: Hsla,
164 /// Table background color.
165 pub table: Hsla,
166 /// Table active item background color.
167 pub table_active: Hsla,
168 /// Table active item border color.
169 pub table_active_border: Hsla,
170 /// Stripe background color for even TableRow.
171 pub table_even: Hsla,
172 /// Table head background color.
173 pub table_head: Hsla,
174 /// Table head text color.
175 pub table_head_foreground: Hsla,
176 /// Table item hover background color.
177 pub table_hover: Hsla,
178 /// Table row border color.
179 pub table_row_border: Hsla,
180 /// TitleBar background color, use for Window title bar.
181 pub title_bar: Hsla,
182 /// TitleBar border color.
183 pub title_bar_border: Hsla,
184 /// Background color for Tiles.
185 pub tiles: Hsla,
186 /// Warning background color.
187 pub warning: Hsla,
188 /// Warning active background color.
189 pub warning_active: Hsla,
190 /// Warning hover background color.
191 pub warning_hover: Hsla,
192 /// Warning foreground color.
193 pub warning_foreground: Hsla,
194 /// Overlay background color.
195 pub overlay: Hsla,
196 /// Window border color.
197 ///
198 /// # Platform specific:
199 ///
200 /// This is only works on Linux, other platforms we can't change the window border color.
201 pub window_border: Hsla,
202
203 /// The base red color.
204 pub red: Hsla,
205 /// The base red light color.
206 pub red_light: Hsla,
207 /// The base green color.
208 pub green: Hsla,
209 /// The base green light color.
210 pub green_light: Hsla,
211 /// The base blue color.
212 pub blue: Hsla,
213 /// The base blue light color.
214 pub blue_light: Hsla,
215 /// The base yellow color.
216 pub yellow: Hsla,
217 /// The base yellow light color.
218 pub yellow_light: Hsla,
219 /// The base magenta color.
220 pub magenta: Hsla,
221 /// The base magenta light color.
222 pub magenta_light: Hsla,
223 /// The base cyan color.
224 pub cyan: Hsla,
225 /// The base cyan light color.
226 pub cyan_light: Hsla,
227}
228
229impl ThemeColor {
230 /// Get the default light theme colors.
231 pub fn light() -> Arc<Self> {
232 DEFAULT_THEME_COLORS[&ThemeMode::Light].0.clone()
233 }
234
235 /// Get the default dark theme colors.
236 pub fn dark() -> Arc<Self> {
237 DEFAULT_THEME_COLORS[&ThemeMode::Dark].0.clone()
238 }
239}