Skip to main content

Crate gpui_ui_kit_macros

Crate gpui_ui_kit_macros 

Source
Expand description

Proc macros for gpui-ui-kit

Provides derive macros to reduce boilerplate in component theme definitions. The primary macro is ComponentTheme which generates Default and From<&Theme> implementations for theme structs, reducing repetitive boilerplate code.

§Quick Start

use gpui_ui_kit_macros::ComponentTheme;

#[derive(Debug, Clone, ComponentTheme)]
pub struct MyComponentTheme {
    #[theme(default = 0x007acc, from = accent)]
    pub primary_color: Rgba,

    #[theme(default = 0xffffff, from = text_primary)]
    pub text_color: Rgba,
}

This generates:

  • impl Default for MyComponentTheme using the hex default values
  • impl From<&Theme> for MyComponentTheme mapping from global theme fields

§Crate Features

This is a proc-macro crate. It must be used alongside the main gpui-ui-kit crate which re-exports the macro as ComponentTheme.

Derive Macros§

ComponentTheme
Derive macro for component themes.