← All Workshops
Intro to Dioxus 0.7
Step 2 / 6
Components & Props
Components are the building blocks of a Dioxus UI. They are plain functions
annotated with `#[component]` that return `Element`. Props are just function
arguments — no macro magic needed.
src/main.rs
#[component]
fn Greeting(name: String) -> Element {
rsx! {
div {
class: "greeting",
"Hello, {name}!"
}
}
}
💡 Tip: Props must be owned
Props must implement `PartialEq` and `Clone`. Use `String` instead of `&str`.
Step 2 / 6