1
0

component_children.rs 740 B

123456789101112131415161718192021222324252627282930313233343536
  1. // ANCHOR: all
  2. #![allow(non_snake_case)]
  3. use dioxus::prelude::*;
  4. fn main() {
  5. dioxus::desktop::launch(App);
  6. }
  7. fn App(cx: Scope) -> Element {
  8. // ANCHOR: Clickable_usage
  9. cx.render(rsx! {
  10. Clickable {
  11. href: "https://www.youtube.com/watch?v=C-M2hs3sXGo",
  12. "How to " i {"not"} " be seen"
  13. }
  14. })
  15. // ANCHOR_END: Clickable_usage
  16. }
  17. // ANCHOR: Clickable
  18. #[derive(Props)]
  19. struct ClickableProps<'a> {
  20. href: &'a str,
  21. children: Element<'a>,
  22. }
  23. fn Clickable<'a>(cx: Scope<'a, ClickableProps<'a>>) -> Element {
  24. cx.render(rsx!(
  25. a {
  26. href: "{cx.props.href}",
  27. class: "fancy-button",
  28. &cx.props.children
  29. }
  30. ))
  31. }
  32. // ANCHOR_END: Clickable