Skip to content

Commit 2f62163

Browse files
committed
tab bar now follows iced's native theme and not hardcoded values
1 parent 2671392 commit 2f62163

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/style/tab_bar.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ impl StyleSheet for Theme {
103103

104104
fn active(&self, style: &Self::Style, is_active: bool) -> Appearance {
105105
let mut appearance = Appearance::default();
106+
let palette = self.extended_palette();
106107

107108
match style {
108109
TabBarStyles::Default => {
109110
appearance.tab_label_background = if is_active {
110-
Background::Color([0.9, 0.9, 0.9].into())
111+
Background::Color(palette.primary.base.color)
111112
} else {
112-
Background::Color([0.87, 0.87, 0.87].into())
113+
Background::Color(palette.background.strong.color)
113114
};
115+
appearance.text_color = palette.background.base.text;
114116
}
115117
TabBarStyles::Dark => {
116118
appearance.tab_label_background = if is_active {
@@ -186,9 +188,14 @@ impl StyleSheet for Theme {
186188
}
187189

188190
fn hovered(&self, style: &Self::Style, is_active: bool) -> Appearance {
191+
let palette = self.extended_palette();
189192
match style {
190193
TabBarStyles::Default => Appearance {
191-
tab_label_background: Background::Color([0.9, 0.9, 0.9].into()),
194+
tab_label_background: Background::Color(if is_active {
195+
palette.background.strong.color
196+
} else {
197+
palette.primary.strong.color
198+
}),
192199
..self.active(style, is_active)
193200
},
194201
TabBarStyles::Dark => Appearance {

0 commit comments

Comments
 (0)