How to stop the text from a button from having its own background color?

For things like:

                       Factory::from_factory(move || {
                            let red = day == today;
                            Cell::from(Button::new(Text::new(day))).style(if red {
                                Style {
                                    background: Some(Background::Color(Color::from_rgb8(255, 0, 0))),
                                    text_color: Some(Color::from_rgb8(255, 255, 255)),
                                    ..Style::default()
                                }
                            } else {
                                Style {
                                    background: Some(Background::Color(Color::from_rgb8(255, 255, 255))),
                                    text_color: Some(Color::from_rgb8(0, 0, 0)),
                                    ..Style::default()
                                }
                            })
                        })

You can see there is a button going to be made, it used to be a text, and when it was a text, I had no issue with styling, there was no background color like what you see in the image (that blue background color). So why is it present with a button? and how do I stop it?

Full code:
pastebin/c142YgEk
repo:
github SpiderUnderUrBed/iced-calendar-rs

From what I can tell, that blue background is the default background color for a button using the default theme. You’d need to change the button style from the default to get rid of that. I’m not quite sure why the text has its own black (it could actually be transparent) background though.

So I figured it out, turns out I misplaced a comma! well, more specifically I forgot to style the BUTTON itself, I either styled the text or container. So this issue is solved.

1 Like