mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-30 16:09:12 +00:00
37 lines
810 B
Rust
37 lines
810 B
Rust
//! Example: The basics of Dioxus
|
|
//! ----------------------------
|
|
//!
|
|
//! This small example covers some of the basics of Dioxus including
|
|
//! - Components
|
|
//! - Props
|
|
//! - Children
|
|
//! - the rsx! macro
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
pub static Example: FC<()> = |(cx, props)| {
|
|
cx.render(rsx! {
|
|
div {
|
|
Greeting {
|
|
name: "Dioxus"
|
|
div { "Dioxus is a fun, fast, and portable UI framework for Rust" }
|
|
}
|
|
}
|
|
})
|
|
};
|
|
|
|
#[derive(PartialEq, Props)]
|
|
struct GreetingProps {
|
|
name: &'static str,
|
|
}
|
|
|
|
static Greeting: FC<GreetingProps> = |(cx, props)| {
|
|
cx.render(rsx! {
|
|
div {
|
|
h1 { "Hello, {props.name}!" }
|
|
p { "Welcome to the Dioxus framework" }
|
|
br {}
|
|
{cx.children()}
|
|
}
|
|
})
|
|
};
|