/concoct

An experimental cross-platform UI framework in rust.

Primary LanguageRust

Concoct

crate Rust Documentation CI

Cross-platform UI framework in Rust with

  • Easy functional composasbles
  • Flexible state management
  • Desktop and mobile support
  • Accessibility
  • Native skia rendering

Examples

wallet example counter example

Hello World

use concoct::{composable::text, render::run, Modifier};

fn app() {
    text(Modifier::default(), "Hello World!")
}

fn main() {
    run(app)
}

Creating a composable

To create your own composable, write a function using Rust's #[track_caller] attribute macro.

#[track_caller]
fn title_text(title: String) {
    text(Modifier::default().font_size(80.dp()), title);
}

State

State is created with the state composable.

let mut tester = Tester::new(|| {
    container(Modifier::default(), || {
        let count = state(|| 0);

        text(Modifier::default(), count.get().cloned().to_string());

        *count.get().as_mut() += 1;
    })
});

for count in 0..5 {
    assert!(tester.get_text(count.to_string()).is_some());
}