theme_provider

Function theme_provider 

Source
pub fn theme_provider<V, F>(child: F, options: ProviderOptions) -> V
where F: Fn() -> V, V: IntoView + 'static,
Expand description

Wrapper function that provides all necessary things in context for hot reloading to work

§Example

§style.css

body {
    flex-grow: 1;
}

my-header {
    font-size: 32px;
    font-weight: 600;
}

§main.rs

use floem::views::{container, text};
use floem::IntoView;
use floem_css::{theme_provider, ProviderOptions, StyleCss};

fn main() {
    // Styles are read from this path.
    // Modify the css file to instantly see changes in app.
    // Path can point to file or folder.
    let options = ProviderOptions {
        path: "./examples/style.css".into(),
        ..Default::default()
    };

    // Wrap your app in theme_provider and launch
    floem::launch(|| theme_provider(main_view, options))
}

fn main_view() -> impl IntoView {
    let my_text = text("Change my style").css("my-header");
    container(my_text).css("body")
}

§Panics

Panics if options path doesn’t exist in filesystem or is otherwise unreadable