pub struct Style { /* private fields */ }Expand description
A CSS style builder that provides a fluent API for creating CSS styles.
The Style struct is the main entry point for building CSS styles. It maintains
an internal collection of CSS properties and provides methods for adding and
manipulating these properties. The fluent API design allows for chaining method
calls to create complex styles in a readable, declarative manner.
§Examples
Basic usage:
use mew_css::style;
use mew_css::values::{Color, Size};
let css = style()
.color(Color::Blue)
.font_size(Size::Px(16))
.apply();The resulting CSS string will be: color: blue; font-size: 16px;
Implementations§
Source§impl Style
impl Style
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty style with no properties.
This is the starting point for building a CSS style. After creating a new style, you can chain method calls to add properties.
§Examples
use mew_css::style::Style;
let style = Style::new();More commonly, you’ll use the style() function:
use mew_css::style;
let style = style();Sourcepub fn add_property(&mut self, property: Property) -> &mut Self
pub fn add_property(&mut self, property: Property) -> &mut Self
Adds a property to the style and returns a mutable reference to self.
This is a low-level method used by the property-specific methods. Most users won’t need to call this directly, but it’s useful for extending the library with custom properties.
§Arguments
property- The CSS property to add
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::properties::Property;
let css = style()
.add_property(Property::new("color", "blue"))
.add_property(Property::new("font-size", "16px"))
.apply();Sourcepub fn apply(&self) -> String
pub fn apply(&self) -> String
Generates the final CSS string from all added properties.
This method should be called after adding all desired properties to generate
the CSS string. It formats each property as name: value; and joins them
with spaces.
§Returns
A string containing the CSS representation of all properties
§Examples
use mew_css::style;
use mew_css::values::{Color, Size};
let css = style()
.color(Color::Blue)
.font_size(Size::Px(16))
.apply();
assert_eq!(css, "color: blue; font-size: 16px;");Examples found in repository?
4fn main() {
5 // Create a style with directional border properties
6 let css = style()
7 .border_top(Size::Px(1), BorderStyle::Solid, Color::Red)
8 .border_right(Size::Px(2), BorderStyle::Dashed, Color::Blue)
9 .border_bottom(Size::Px(3), BorderStyle::Dotted, Color::Green)
10 .border_left(Size::Px(4), BorderStyle::Double, Color::Black)
11 .apply();
12
13 println!("Generated CSS with directional borders:");
14 println!("{}", css);
15}More examples
4fn main() {
5 // Create a CSS style using the mew library
6 let css = style()
7 .color(Color::Blue)
8 .background_color(Color::Rgb(240, 240, 240))
9 .font_size(Size::Px(18))
10 .display(Display::Block)
11 .apply();
12
13 println!("Generated CSS: {}", css);
14
15 // Verify the output
16 let expected = "color: blue; background-color: rgb(240, 240, 240); font-size: 18px; display: block;";
17 assert_eq!(css, expected);
18
19 println!("Example completed successfully!");
20}5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn build(&self) -> String
pub fn build(&self) -> String
Alias for apply() that generates the CSS string.
This method provides an alternative name that might be more intuitive in some contexts.
§Returns
A string containing the CSS representation of all properties
§Examples
use mew_css::style;
use mew_css::values::{Color, Size};
let css = style()
.color(Color::Blue)
.font_size(Size::Px(16))
.build();
assert_eq!(css, "color: blue; font-size: 16px;");Sourcepub fn custom_property<T: Display>(&mut self, name: &str, value: T) -> &mut Self
pub fn custom_property<T: Display>(&mut self, name: &str, value: T) -> &mut Self
Adds a custom property with the given name and value.
This method allows you to add any CSS property, including those not explicitly supported by the library. It’s useful for experimental properties, vendor-prefixed properties, or any other property not covered by the built-in methods.
§Arguments
name- The CSS property namevalue- The property value, which can be any type that implementsDisplay
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
let css = style()
.custom_property("animation-name", "fade-in")
.custom_property("animation-duration", "2s")
.apply();
assert_eq!(css, "animation-name: fade-in; animation-duration: 2s;");Sourcepub fn set_var<T: Display>(&mut self, name: &str, value: T) -> &mut Self
pub fn set_var<T: Display>(&mut self, name: &str, value: T) -> &mut Self
Defines a CSS custom property (CSS variable).
This method adds a CSS variable definition to the style. CSS variables are defined
with the -- prefix and can be referenced using the var() function.
§Arguments
name- The variable name (with or without the--prefix)value- The variable value, which can be any type that implementsDisplay
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
let css = style()
.set_var("primary-color", "#3366ff")
.set_var("spacing", "1rem")
.apply();
assert_eq!(css, "--primary-color: #3366ff; --spacing: 1rem;");The -- prefix is added automatically if not present:
use mew_css::style;
let css = style()
.set_var("--primary-color", "#3366ff") // With prefix
.set_var("spacing", "1rem") // Without prefix
.apply();
assert_eq!(css, "--primary-color: #3366ff; --spacing: 1rem;");Sourcepub fn color(&mut self, value: Color) -> &mut Self
pub fn color(&mut self, value: Color) -> &mut Self
Sets the text color of an element.
The color property specifies the color of text content and text decorations.
It can be set using named colors, RGB/RGBA values, HSL/HSLA values, or hex codes.
§Arguments
value- The color value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::Color;
// Using a named color
let css1 = style().color(Color::Red).apply();
// Using RGB values
let css2 = style().color(Color::Rgb(255, 0, 0)).apply();
// Using RGBA values with transparency
let css3 = style().color(Color::Rgba(255, 0, 0, 0.5)).apply();
// Using a hex color
let css4 = style().color(Color::Hex("#ff0000".to_string())).apply();Examples found in repository?
4fn main() {
5 // Create a CSS style using the mew library
6 let css = style()
7 .color(Color::Blue)
8 .background_color(Color::Rgb(240, 240, 240))
9 .font_size(Size::Px(18))
10 .display(Display::Block)
11 .apply();
12
13 println!("Generated CSS: {}", css);
14
15 // Verify the output
16 let expected = "color: blue; background-color: rgb(240, 240, 240); font-size: 18px; display: block;";
17 assert_eq!(css, expected);
18
19 println!("Example completed successfully!");
20}More examples
5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn background_color(&mut self, value: Color) -> &mut Self
pub fn background_color(&mut self, value: Color) -> &mut Self
Sets the background color of an element.
The background-color property sets the background color of an element.
The background covers the element’s content, padding, and border areas.
§Arguments
value- The color value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::Color;
// Using a named color
let css1 = style().background_color(Color::LightGray).apply();
// Using RGB values
let css2 = style().background_color(Color::Rgb(240, 240, 240)).apply();
// Using RGBA values with transparency
let css3 = style().background_color(Color::Rgba(240, 240, 240, 0.5)).apply();Examples found in repository?
4fn main() {
5 // Create a CSS style using the mew library
6 let css = style()
7 .color(Color::Blue)
8 .background_color(Color::Rgb(240, 240, 240))
9 .font_size(Size::Px(18))
10 .display(Display::Block)
11 .apply();
12
13 println!("Generated CSS: {}", css);
14
15 // Verify the output
16 let expected = "color: blue; background-color: rgb(240, 240, 240); font-size: 18px; display: block;";
17 assert_eq!(css, expected);
18
19 println!("Example completed successfully!");
20}More examples
5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn border_color(&mut self, value: Color) -> &mut Self
pub fn border_color(&mut self, value: Color) -> &mut Self
Set the border-color property
Sourcepub fn width(&mut self, value: Size) -> &mut Self
pub fn width(&mut self, value: Size) -> &mut Self
Sets the width of an element.
The width property sets the width of an element’s content area.
It can be specified in various units like pixels, percentages, or relative units.
§Arguments
value- The width value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::Size;
// Fixed width in pixels
let css1 = style().width(Size::Px(300)).apply();
// Percentage width (relative to parent)
let css2 = style().width(Size::Percent(100.0)).apply();
// Auto width
let css3 = style().width(Size::Auto).apply();
// Viewport-relative width
let css4 = style().width(Size::Vw(50.0)).apply();Sourcepub fn height(&mut self, value: Size) -> &mut Self
pub fn height(&mut self, value: Size) -> &mut Self
Sets the height of an element.
The height property sets the height of an element’s content area.
Like width, it can be specified in various units.
§Arguments
value- The height value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::Size;
// Fixed height in pixels
let css1 = style().height(Size::Px(200)).apply();
// Percentage height (requires parent to have a defined height)
let css2 = style().height(Size::Percent(100.0)).apply();
// Viewport-relative height
let css3 = style().height(Size::Vh(100.0)).apply();Sourcepub fn margin(&mut self, value: Size) -> &mut Self
pub fn margin(&mut self, value: Size) -> &mut Self
Sets the margin around an element.
The margin property creates space around an element, outside of any defined
borders. It sets the margin on all four sides at once (top, right, bottom, left).
§Arguments
value- The margin value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::Size;
// Fixed margin in pixels
let css1 = style().margin(Size::Px(10)).apply();
// Auto margin (useful for horizontal centering)
let css2 = style().margin(Size::Auto).apply();
// Relative margin using em
let css3 = style().margin(Size::Em(1.5)).apply();For directional margins, use the specific methods:
margin_top(), margin_right(), margin_bottom(), margin_left()
Examples found in repository?
5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn margin_top(&mut self, value: Size) -> &mut Self
pub fn margin_top(&mut self, value: Size) -> &mut Self
Set the margin-top property
Sourcepub fn margin_right(&mut self, value: Size) -> &mut Self
pub fn margin_right(&mut self, value: Size) -> &mut Self
Set the margin-right property
Sourcepub fn margin_bottom(&mut self, value: Size) -> &mut Self
pub fn margin_bottom(&mut self, value: Size) -> &mut Self
Set the margin-bottom property
Sourcepub fn margin_left(&mut self, value: Size) -> &mut Self
pub fn margin_left(&mut self, value: Size) -> &mut Self
Set the margin-left property
Sourcepub fn padding(&mut self, value: Size) -> &mut Self
pub fn padding(&mut self, value: Size) -> &mut Self
Set the padding property
Examples found in repository?
5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn padding_top(&mut self, value: Size) -> &mut Self
pub fn padding_top(&mut self, value: Size) -> &mut Self
Set the padding-top property
Sourcepub fn padding_right(&mut self, value: Size) -> &mut Self
pub fn padding_right(&mut self, value: Size) -> &mut Self
Set the padding-right property
Sourcepub fn padding_bottom(&mut self, value: Size) -> &mut Self
pub fn padding_bottom(&mut self, value: Size) -> &mut Self
Set the padding-bottom property
Sourcepub fn padding_left(&mut self, value: Size) -> &mut Self
pub fn padding_left(&mut self, value: Size) -> &mut Self
Set the padding-left property
Sourcepub fn font_size(&mut self, value: Size) -> &mut Self
pub fn font_size(&mut self, value: Size) -> &mut Self
Set the font-size property
Examples found in repository?
4fn main() {
5 // Create a CSS style using the mew library
6 let css = style()
7 .color(Color::Blue)
8 .background_color(Color::Rgb(240, 240, 240))
9 .font_size(Size::Px(18))
10 .display(Display::Block)
11 .apply();
12
13 println!("Generated CSS: {}", css);
14
15 // Verify the output
16 let expected = "color: blue; background-color: rgb(240, 240, 240); font-size: 18px; display: block;";
17 assert_eq!(css, expected);
18
19 println!("Example completed successfully!");
20}Sourcepub fn line_height(&mut self, value: Size) -> &mut Self
pub fn line_height(&mut self, value: Size) -> &mut Self
Set the line-height property
Sourcepub fn border_width(&mut self, value: Size) -> &mut Self
pub fn border_width(&mut self, value: Size) -> &mut Self
Set the border-width property
Sourcepub fn display(&mut self, value: Display) -> &mut Self
pub fn display(&mut self, value: Display) -> &mut Self
Sets how an element is displayed in the layout.
The display property determines how an element is treated in the layout flow
and how its children are laid out. This is one of the most important CSS properties
for controlling layout.
§Arguments
value- The display value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::Display;
// Block layout (element takes up full width)
let css1 = style().display(Display::Block).apply();
// Inline layout (element flows with text)
let css2 = style().display(Display::Inline).apply();
// Flexbox layout
let css3 = style().display(Display::Flex).apply();
// Grid layout
let css4 = style().display(Display::Grid).apply();
// Hide element
let css5 = style().display(Display::None).apply();Examples found in repository?
4fn main() {
5 // Create a CSS style using the mew library
6 let css = style()
7 .color(Color::Blue)
8 .background_color(Color::Rgb(240, 240, 240))
9 .font_size(Size::Px(18))
10 .display(Display::Block)
11 .apply();
12
13 println!("Generated CSS: {}", css);
14
15 // Verify the output
16 let expected = "color: blue; background-color: rgb(240, 240, 240); font-size: 18px; display: block;";
17 assert_eq!(css, expected);
18
19 println!("Example completed successfully!");
20}More examples
5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn position(&mut self, value: Position) -> &mut Self
pub fn position(&mut self, value: Position) -> &mut Self
Sets the positioning method for an element.
The position property specifies how an element is positioned in the document.
It works together with the top, right, bottom, and left properties to
determine the final position of the element.
§Arguments
value- The position value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::{Position, Size};
// Static positioning (default flow)
let css1 = style().position(Position::Static).apply();
// Relative positioning (offset from normal position)
let css2 = style()
.position(Position::Relative)
.top(Size::Px(10))
.left(Size::Px(20))
.apply();
// Absolute positioning (relative to nearest positioned ancestor)
let css3 = style()
.position(Position::Absolute)
.top(Size::Px(0))
.right(Size::Px(0))
.apply();
// Fixed positioning (relative to viewport)
let css4 = style()
.position(Position::Fixed)
.bottom(Size::Px(20))
.right(Size::Px(20))
.apply();Sourcepub fn flex_direction(&mut self, value: FlexDirection) -> &mut Self
pub fn flex_direction(&mut self, value: FlexDirection) -> &mut Self
Sets the direction of flex items within a flex container.
The flex-direction property establishes the main axis of a flex container,
defining the direction in which flex items are placed. This property only
applies to elements with display: flex.
§Arguments
value- The flex-direction value to set
§Returns
A mutable reference to self for method chaining
§Examples
use mew_css::style;
use mew_css::values::{Display, FlexDirection};
// Create a horizontal flex container (default)
let css1 = style()
.display(Display::Flex)
.flex_direction(FlexDirection::Row)
.apply();
// Create a vertical flex container
let css2 = style()
.display(Display::Flex)
.flex_direction(FlexDirection::Column)
.apply();
// Reverse the order of items
let css3 = style()
.display(Display::Flex)
.flex_direction(FlexDirection::RowReverse)
.apply();Sourcepub fn justify_content(&mut self, value: JustifyContent) -> &mut Self
pub fn justify_content(&mut self, value: JustifyContent) -> &mut Self
Set the justify-content property
Sourcepub fn align_items(&mut self, value: AlignItems) -> &mut Self
pub fn align_items(&mut self, value: AlignItems) -> &mut Self
Set the align-items property
Sourcepub fn font_weight(&mut self, value: FontWeight) -> &mut Self
pub fn font_weight(&mut self, value: FontWeight) -> &mut Self
Set the font-weight property
Examples found in repository?
5fn main() {
6 // Create CSS variables
7 let primary_color = var("primary-color");
8 let spacing = var("spacing");
9 let display_mode = var("display-mode");
10 let font_weight = var("font-weight");
11
12 // Use CSS variables in style properties
13 // Method 1: Using explicit enum variants
14 let css1 = style()
15 .color(Color::Var(primary_color.clone()))
16 .background_color(Color::Rgba(240, 240, 240, 0.5))
17 .margin(Size::Var(spacing.clone()))
18 .padding(Size::Px(10))
19 .display(Display::Var(display_mode.clone()))
20 .font_weight(FontWeight::Var(font_weight.clone()))
21 .apply();
22
23 // Method 2: Using Into trait
24 let css2 = style()
25 .color(primary_color.clone().into())
26 .background_color(Color::Rgba(240, 240, 240, 0.5))
27 .margin(spacing.clone().into())
28 .padding(Size::Px(10))
29 .display(display_mode.into())
30 .font_weight(font_weight.into())
31 .apply();
32
33 println!("Generated CSS with variables (Method 1): {}", css1);
34 println!("Generated CSS with variables (Method 2): {}", css2);
35}Sourcepub fn font_family(&mut self, value: &str) -> &mut Self
pub fn font_family(&mut self, value: &str) -> &mut Self
Set the font-family property
Sourcepub fn text_align(&mut self, value: TextAlign) -> &mut Self
pub fn text_align(&mut self, value: TextAlign) -> &mut Self
Set the text-align property
Sourcepub fn font_size_enum(&mut self, value: FontSize) -> &mut Self
pub fn font_size_enum(&mut self, value: FontSize) -> &mut Self
Set the font-size property with FontSize enum
Sourcepub fn line_height_enum(&mut self, value: LineHeight) -> &mut Self
pub fn line_height_enum(&mut self, value: LineHeight) -> &mut Self
Set the line-height property with LineHeight enum
Sourcepub fn text_decoration(&mut self, value: TextDecoration) -> &mut Self
pub fn text_decoration(&mut self, value: TextDecoration) -> &mut Self
Set the text-decoration property
Sourcepub fn border_style(&mut self, value: BorderStyle) -> &mut Self
pub fn border_style(&mut self, value: BorderStyle) -> &mut Self
Set the border-style property
Sourcepub fn border_radius(&mut self, value: Size) -> &mut Self
pub fn border_radius(&mut self, value: Size) -> &mut Self
Set the border-radius property
Sourcepub fn border(
&mut self,
width: Size,
style: BorderStyle,
color: Color,
) -> &mut Self
pub fn border( &mut self, width: Size, style: BorderStyle, color: Color, ) -> &mut Self
Set the border property (shorthand)
Sourcepub fn border_top(
&mut self,
width: Size,
style: BorderStyle,
color: Color,
) -> &mut Self
pub fn border_top( &mut self, width: Size, style: BorderStyle, color: Color, ) -> &mut Self
Set the border-top property (shorthand)
Examples found in repository?
4fn main() {
5 // Create a style with directional border properties
6 let css = style()
7 .border_top(Size::Px(1), BorderStyle::Solid, Color::Red)
8 .border_right(Size::Px(2), BorderStyle::Dashed, Color::Blue)
9 .border_bottom(Size::Px(3), BorderStyle::Dotted, Color::Green)
10 .border_left(Size::Px(4), BorderStyle::Double, Color::Black)
11 .apply();
12
13 println!("Generated CSS with directional borders:");
14 println!("{}", css);
15}Sourcepub fn border_right(
&mut self,
width: Size,
style: BorderStyle,
color: Color,
) -> &mut Self
pub fn border_right( &mut self, width: Size, style: BorderStyle, color: Color, ) -> &mut Self
Set the border-right property (shorthand)
Examples found in repository?
4fn main() {
5 // Create a style with directional border properties
6 let css = style()
7 .border_top(Size::Px(1), BorderStyle::Solid, Color::Red)
8 .border_right(Size::Px(2), BorderStyle::Dashed, Color::Blue)
9 .border_bottom(Size::Px(3), BorderStyle::Dotted, Color::Green)
10 .border_left(Size::Px(4), BorderStyle::Double, Color::Black)
11 .apply();
12
13 println!("Generated CSS with directional borders:");
14 println!("{}", css);
15}Sourcepub fn border_bottom(
&mut self,
width: Size,
style: BorderStyle,
color: Color,
) -> &mut Self
pub fn border_bottom( &mut self, width: Size, style: BorderStyle, color: Color, ) -> &mut Self
Set the border-bottom property (shorthand)
Examples found in repository?
4fn main() {
5 // Create a style with directional border properties
6 let css = style()
7 .border_top(Size::Px(1), BorderStyle::Solid, Color::Red)
8 .border_right(Size::Px(2), BorderStyle::Dashed, Color::Blue)
9 .border_bottom(Size::Px(3), BorderStyle::Dotted, Color::Green)
10 .border_left(Size::Px(4), BorderStyle::Double, Color::Black)
11 .apply();
12
13 println!("Generated CSS with directional borders:");
14 println!("{}", css);
15}Sourcepub fn border_left(
&mut self,
width: Size,
style: BorderStyle,
color: Color,
) -> &mut Self
pub fn border_left( &mut self, width: Size, style: BorderStyle, color: Color, ) -> &mut Self
Set the border-left property (shorthand)
Examples found in repository?
4fn main() {
5 // Create a style with directional border properties
6 let css = style()
7 .border_top(Size::Px(1), BorderStyle::Solid, Color::Red)
8 .border_right(Size::Px(2), BorderStyle::Dashed, Color::Blue)
9 .border_bottom(Size::Px(3), BorderStyle::Dotted, Color::Green)
10 .border_left(Size::Px(4), BorderStyle::Double, Color::Black)
11 .apply();
12
13 println!("Generated CSS with directional borders:");
14 println!("{}", css);
15}Sourcepub fn box_shadow(&mut self, value: BoxShadow) -> &mut Self
pub fn box_shadow(&mut self, value: BoxShadow) -> &mut Self
Set the box-shadow property
Sourcepub fn box_shadow_none(&mut self) -> &mut Self
pub fn box_shadow_none(&mut self) -> &mut Self
Set the box-shadow property to none
Sourcepub fn overflow_x(&mut self, value: Overflow) -> &mut Self
pub fn overflow_x(&mut self, value: Overflow) -> &mut Self
Set the overflow-x property
Sourcepub fn overflow_y(&mut self, value: Overflow) -> &mut Self
pub fn overflow_y(&mut self, value: Overflow) -> &mut Self
Set the overflow-y property
Sourcepub fn visibility(&mut self, value: Visibility) -> &mut Self
pub fn visibility(&mut self, value: Visibility) -> &mut Self
Set the visibility property
Sourcepub fn column_gap(&mut self, value: Size) -> &mut Self
pub fn column_gap(&mut self, value: Size) -> &mut Self
Set the column-gap property
Sourcepub fn grid_template_columns(&mut self, value: &str) -> &mut Self
pub fn grid_template_columns(&mut self, value: &str) -> &mut Self
Set the grid-template-columns property
Sourcepub fn grid_template_rows(&mut self, value: &str) -> &mut Self
pub fn grid_template_rows(&mut self, value: &str) -> &mut Self
Set the grid-template-rows property
Sourcepub fn transition(&mut self, value: Transition) -> &mut Self
pub fn transition(&mut self, value: Transition) -> &mut Self
Set the transition property
Sourcepub fn transition_none(&mut self) -> &mut Self
pub fn transition_none(&mut self) -> &mut Self
Set the transition property to none
Sourcepub fn transition_all(
&mut self,
duration: f32,
timing_function: Option<&str>,
delay: Option<f32>,
) -> &mut Self
pub fn transition_all( &mut self, duration: f32, timing_function: Option<&str>, delay: Option<f32>, ) -> &mut Self
Set the transition property to all
Sourcepub fn max_height(&mut self, value: Size) -> &mut Self
pub fn max_height(&mut self, value: Size) -> &mut Self
Set the max-height property
Sourcepub fn min_height(&mut self, value: Size) -> &mut Self
pub fn min_height(&mut self, value: Size) -> &mut Self
Set the min-height property