Expand description
§OpenKit
A cross-platform CSS-styled UI framework for Rust.
OpenKit provides a consistent, beautiful UI experience across Windows, macOS, Linux, and FreeBSD with CSS-powered styling and a Tailwind-inspired design system.
§Supported Platforms
- Windows: Windows 10 and later
- macOS: macOS 10.15 (Catalina) and later
- Linux: X11 and Wayland (GNOME, KDE, Sway, Hyprland, etc.)
- FreeBSD: X11 with common desktop environments
§Quick Start
ⓘ
use openkit::prelude::*;
App::new()
.title("My App")
.theme(Theme::Auto)
.run(|| {
col![16;
label!("Hello, OpenKit!"),
button!("Click me", { println!("Clicked!"); }),
]
});§Declarative Macros
OpenKit provides ergonomic macros for building UIs:
use openkit::prelude::*;
// Layout macros
let ui = col![16; // Column with 16px gap
label!("Welcome!"),
row![8; // Row with 8px gap
button!("OK", { /* handler */ }),
button!("Cancel", Secondary),
],
];
// Widget macros
let btn = button!("Save", { println!("Saved!"); });
let cb = checkbox!("Enable", |checked| println!("{}", checked));
let tf = textfield!("Enter name...", |val| println!("{}", val));
// Utility macros
let classes = class!["btn", "primary", "large"];
let styles = style! { padding: 16, color: "blue" };Re-exports§
pub use crate::app::AppError;
Modules§
- app
- Application entry point and lifecycle management.
- component
- Angular-inspired component system for OpenKit.
- css
- CSS parsing and style engine for OpenKit.
- event
- Event types for OpenKit.
- geometry
- Geometry primitives for OpenKit.
- layout
- Layout engine for OpenKit.
- macros
- Declarative macros for ergonomic UI building.
- platform
- Platform abstraction layer.
- prelude
- Convenient re-exports for common types.
- render
- Rendering engine for OpenKit.
- theme
- Theme system for OpenKit.
- widget
- Widget system for OpenKit.
Macros§
- bind
- Property binding macro (like [property]=“value”).
- button
- Create a button with an inline click handler.
- checkbox
- Create a labeled checkbox with an inline change handler.
- class
- Combine multiple CSS class names.
- col
- Quick column layout macro.
- dbg_
widget - Debug helper - prints widget tree structure.
- define_
component - Define a component with Angular-like syntax.
- for_
each - Iterate and create widgets from a collection.
- label
- Create a label with optional styling.
- match_
widget - Match-based widget selection.
- model
- Two-way binding macro (like [(ngModel)]=“value”).
- ng_for
- Structural for directive.
- ng_if
- Structural if directive.
- ng_
switch - Structural switch directive.
- on
- Event binding macro (like (event)=“handler()”).
- row
- Quick row layout macro.
- spacer
- Create a spacer widget that expands to fill available space.
- style
- Inline style macro with CSS-like syntax.
- textfield
- Create a text field with placeholder and change handler.
- view
- Declarative view macro for building widget trees.
- when
- Conditional widget rendering.
Attribute Macros§
- component
- Attribute macro for defining components with inline render function.
- event
- Attribute macro for marking event emitters.
- prop
- Attribute macro for marking component properties.
- state
- Attribute macro for marking component state.