pub struct Style { /* private fields */ }Expand description
Builds inline CSS from Rust values, for style={...} attributes whose
values are computed.
use eternal_ui::Style;
let width = 120.0;
let style = Style::new().width_px(width).padding_px(4.0).set("color", "#fff");
assert_eq!(style.to_string(), "width: 120px; padding: 4px; color: #fff");The result is parsed by eternal-styler like any other CSS, so a property it does not know is reported when the element is built.
Implementations§
Source§impl Style
impl Style
pub fn new() -> Self
Sourcepub fn set(self, property: &str, value: impl Display) -> Self
pub fn set(self, property: &str, value: impl Display) -> Self
Any property and value, as CSS text.
pub fn width_px(self, px: f32) -> Self
pub fn height_px(self, px: f32) -> Self
pub fn min_width_px(self, px: f32) -> Self
pub fn min_height_px(self, px: f32) -> Self
pub fn padding_px(self, px: f32) -> Self
pub fn margin_px(self, px: f32) -> Self
pub fn gap_px(self, px: f32) -> Self
Sourcepub fn color(self, css: &str) -> Self
pub fn color(self, css: &str) -> Self
Any CSS colour syntax, such as #1e1e1e or oklch(60% 0.1 250).
pub fn background(self, css: &str) -> Self
Sourcepub fn border(self, width_px: f32, style: &str, color: &str) -> Self
pub fn border(self, width_px: f32, style: &str, color: &str) -> Self
A uniform border: border(1.0, "solid", "#000").
pub fn font_size_px(self, px: f32) -> Self
pub fn opacity(self, opacity: f32) -> Self
pub fn is_empty(&self) -> bool
Trait Implementations§
impl Eq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more