diff --git a/.theme-schema.json b/.theme-schema.json index a85b08f9..287dbb78 100644 --- a/.theme-schema.json +++ b/.theme-schema.json @@ -409,6 +409,10 @@ "description": "Switch background color.", "type": ["string", "null"] }, + "switch.thumb.background": { + "description": "Switch thumb background color.", + "type": ["string", "null"] + }, "tab.background": { "description": "Tab background color.", "type": ["string", "null"] diff --git a/crates/ui/src/switch.rs b/crates/ui/src/switch.rs index 6641a203..942de488 100644 --- a/crates/ui/src/switch.rs +++ b/crates/ui/src/switch.rs @@ -94,8 +94,8 @@ impl RenderOnce for Switch { let toggle_state = window.use_keyed_state(self.id.clone(), cx, |_, _| checked); let (bg, toggle_bg) = match checked { - true => (cx.theme().primary, cx.theme().background), - false => (cx.theme().switch, cx.theme().background), + true => (cx.theme().primary, cx.theme().switch_thumb), + false => (cx.theme().switch, cx.theme().switch_thumb), }; let (bg, toggle_bg) = if self.disabled { diff --git a/crates/ui/src/theme/schema.rs b/crates/ui/src/theme/schema.rs index 48d613ca..166de9fe 100644 --- a/crates/ui/src/theme/schema.rs +++ b/crates/ui/src/theme/schema.rs @@ -284,6 +284,9 @@ pub struct ThemeConfigColors { /// Switch background color. #[serde(rename = "switch.background")] pub switch: Option, + /// Switch thumb background color. + #[serde(rename = "switch.thumb.background")] + pub switch_thumb: Option, /// Tab background color. #[serde(rename = "tab.background")] pub tab: Option, @@ -599,6 +602,7 @@ impl ThemeColor { apply_color!(slider_bar, fallback = self.primary); apply_color!(slider_thumb, fallback = self.primary_foreground); apply_color!(switch, fallback = self.secondary); + apply_color!(switch_thumb, fallback = self.background); apply_color!(tab, fallback = self.background); apply_color!(tab_active, fallback = self.background); apply_color!(tab_active_foreground, fallback = self.foreground); diff --git a/crates/ui/src/theme/theme_color.rs b/crates/ui/src/theme/theme_color.rs index 4f7ebfac..c148c494 100644 --- a/crates/ui/src/theme/theme_color.rs +++ b/crates/ui/src/theme/theme_color.rs @@ -149,6 +149,8 @@ pub struct ThemeColor { pub success_active: Hsla, /// Switch background color. pub switch: Hsla, + /// Switch thumb background color. + pub switch_thumb: Hsla, /// Tab background color. pub tab: Hsla, /// Tab active background color.