pub struct Style {
pub background: Option<Color>,
pub color: Option<Color>,
pub font: Option<Font>,
pub padding: Option<Padding>,
pub radius: Option<f32>,
pub border: Option<Border>,
pub opacity: Option<f32>,
}Expand description
How a widget looks. Every field is optional, and an unset field falls back
to the widget’s default: no background, black text in
Font::DEFAULT, no padding, square corners, no border, fully opaque.
Text takes color and font from the nearest widget
that sets them, starting with itself and going up. Nothing else inherits.
font and padding change the layout; the other fields only change how
the widget is painted.
use crabshell_ui::{Color, Font, Style};
const BAR: Style = Style::new()
.background(Color::rgb(0x1e, 0x1e, 0x2e))
.color(Color::hex("#cdd6f4"))
.font(Font::new("Inter", 13.0));
const WS: Style = Style::new().padding(2, 8).radius(4.0);
const WS_FOCUSED: Style = WS.background(Color::rgb(0x45, 0x47, 0x5a));Fields§
§background: Option<Color>Fills the widget’s rectangle.
color: Option<Color>The text color, inherited by Text.
font: Option<Font>The text font, inherited by Text.
padding: Option<Padding>Space between the edge and the content.
radius: Option<f32>The corner radius in logical pixels.
border: Option<Border>A border inside the edge.
opacity: Option<f32>From 0.0 (invisible) to 1.0 (opaque), applied to the widget and everything inside it.
Implementations§
Source§impl Style
impl Style
Sourcepub const fn background(self, color: Color) -> Style
pub const fn background(self, color: Color) -> Style
Sets the background color.
Sourcepub const fn padding(self, vertical: u32, horizontal: u32) -> Style
pub const fn padding(self, vertical: u32, horizontal: u32) -> Style
Sets the padding: vertical above and below, horizontal left and
right, in logical pixels.