Styleable

Derive Macro Styleable 

Source
#[derive(Styleable)]
{
    // Attributes available to this derive:
    #[base]
}
Expand description

Derive macro for CSS styling support.

This macro generates the class() and id() builder methods for adding CSS classes and element IDs to widgets.

§Requirements

  • The struct must have a field marked with #[base] of type WidgetBase

§Example

use openkit_macros::Styleable;

#[derive(Styleable)]
struct MyWidget {
    #[base]
    base: WidgetBase,
    // other fields...
}

// The macro generates:
impl MyWidget {
    pub fn class(mut self, class: &str) -> Self { ... }
    pub fn id(mut self, id: &str) -> Self { ... }
    pub fn classes(&self) -> &ClassList { ... }
}