freya/_docs/
introduction.rs

1//! # Introduction
2//!
3//! **Freya** is a Rust 🦀 library to make GUI applications that are [**cross-platform**](https://en.wikipedia.org/wiki/Cross-platform_software), targeting Windows, macOS and Linux.
4//!
5//! Freya uses a [declarative](https://en.wikipedia.org/wiki/Declarative_programming) model for the UI, and components to encapculate the UI in reusable pieces of code. This is because
6//! Freya uses the core crates 🧬 [Dioxus](https://dioxuslabs.com), a renderer-agnostic components-based and declarative UI library inspired by ReactJS.
7//!
8//! You might have seen that Dioxus renders to HTML, uses CSS/JavaScript/WASM/WebView/WGPU, but this does not apply to Freya.
9//!
10//! As Freya only uses some of the core crates of Dioxus, you will be writing Dioxus components and using some of its APIs but, the elements, attributes, styling, layout, events,
11//! rendering and the rest of things will be provided by Freya.
12//!
13//! Freya uses 🎨 [Skia](https://skia.org/) as rendering engine because its a very battle tested library and has great support for a lot of features.
14//!
15//! #### Example
16//!
17//! ```rust, no_run
18//! # use freya::prelude::*;
19//! fn main() {
20//!     // **Start** your app by specifying the root component, title and size
21//!     launch_with_props(app, "Counter", (400.0, 350.0));
22//! }
23//!
24//! fn app() -> Element {
25//!    // Define a **state**
26//!    let mut count = use_signal(|| 0);
27//!
28//!    // Declare the **UI**
29//!    rsx!(
30//!        rect {
31//!            height: "100%",
32//!            width: "100%",
33//!            background: "rgb(35, 35, 35)",
34//!            color: "white",
35//!            padding: "12",
36//!            onclick: move |_| count += 1, // **Update** the state on click events
37//!            label { "Click to increase -> {count}" } // Display the **state**
38//!        }
39//!    )
40//! }
41//! ```
42//!
43//! #### You can continue to learn more in [UI](crate::_docs::ui).