Skip to main content

Crate mottes_floem_components

Crate mottes_floem_components 

Source
Expand description

§Floem components

floem-components is a component crate for floem. It is split into multiple modules:

  1. theme for color theming
  2. views for standard floem views
  3. classes for floem classes

§Quickstart

use floem::{
    peniko::Color,
    reactive::create_signal,
    views::{button, label, Decorators},
    IntoView,
};
use mottes_floem_components::classes::{construct_theme, Button, Label};
use mottes_floem_components::theme::Theme;

fn app_view() -> impl IntoView {
    let (counter, mut set_counter) = create_signal(0);

    (
        label(move || format!("Value: {counter}")).class(Label),
        (
            button("Increment")
                .action(move || set_counter += 1)
                .class(Button),
            button("Decrement")
                .action(move || set_counter -= 1)
                .class(Button),
        ),
    )
        .style(|_| {
            construct_theme(Theme::dark())
                .flex_col()
                .width_full()
                .height_full()
                .background(Color::parse(Theme::dark().base00).unwrap())
        })
}

fn main() {
    floem::launch(app_view);
}

If you want to see all components in action, look at the gallery example.

Modules§

classes
Classes
theme
Theme
views
Views