Module values

Module values 

Source
Expand description

§CSS Value Types

This module provides strongly-typed representations of CSS values used throughout the Mew CSS library. Each CSS value type is represented as an enum or struct that implements the Display trait for conversion to CSS string representation.

§Design Philosophy

The value types in this module are designed to:

  1. Provide type safety by restricting values to valid CSS options
  2. Enable IDE autocompletion for available values
  3. Handle the correct string formatting for CSS output
  4. Support CSS variables through the Var variant in each enum

§Common Value Types

  • Color: CSS color values (named colors, RGB, RGBA, HSL, HSLA, hex)
  • Size: CSS size values (px, %, em, rem, vw, vh, auto)
  • Display: CSS display property values
  • Position: CSS position property values
  • FontWeight: CSS font-weight property values
  • BorderStyle: CSS border-style property values

§Usage Example

use mew_css::style;
use mew_css::values::{Color, Size, Display};

let css = style()
    .color(Color::Blue)                      // Named color
    .background_color(Color::Rgba(240, 240, 240, 0.5)) // RGBA color
    .width(Size::Percent(100.0))             // Percentage
    .height(Size::Px(200))                   // Pixels
    .margin(Size::Auto)                      // Auto value
    .display(Display::Flex)                  // Display type
    .apply();

Structs§

BoxShadow
Box shadow values
Transition
Transition values

Enums§

AlignItems
Align items values
BorderStyle
Border style values
Color
Represents CSS color values with various formats and named colors.
Cursor
Cursor values
Display
Represents CSS display property values that control how elements are rendered.
FlexDirection
Flex direction values
FontSize
Font size values
FontWeight
Font weight values
JustifyContent
Justify content values
LineHeight
Line height values
Overflow
Overflow values
Position
Represents CSS position property values that control element positioning.
Size
Represents size and length values for CSS properties.
TextAlign
Text align values
TextDecoration
Text decoration values
Visibility
Visibility values
ZIndex
Z-index values