Module ui

Source
Expand description

ยงUI

Freya uses a declarative model for the UI.

For example, this is how the app component would look like in Freya:

fn app() -> impl IntoElement {
    rect()
        .background((255, 0, 0))
        .width(Size::fill())
        .height(Size::px(100.))
        .on_mouse_up(|_| println!("Clicked!"))
}

Notice that the app component is returning an Element, this is because rect() gives you a Rect which implements Into<Element>. So, in other words, the Element contains the UI of that component. Every time the component function reruns a new UI is created and later diffed by Freya internally.