rsx_usage.rs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. use dioxus_core::prelude::*;
  2. fn main() {}
  3. fn Example(ctx: Context, props: ()) -> DomTree {
  4. ctx.render(rsx! {
  5. div {
  6. <h1 tag="type" abc=123 class="big..."> "title1" "title2" </h1>
  7. <h1 alsd> alkjsd </h1>
  8. h1 { tag: "type", abc: 123, class: "big small wide short",
  9. "title1"
  10. "title1"
  11. "title1"
  12. "title"
  13. }
  14. h1 ("title") {
  15. tag: "type",
  16. abc: 123,
  17. class: "big small wide short",
  18. }
  19. // <button
  20. // class="inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
  21. // onclick={move |_| set_name("jill")}
  22. // onclick={move |_| set_name("jill")}
  23. // >
  24. // "Jill!"
  25. // </button>
  26. button { "Jill!",
  27. class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
  28. onclick: move |_| set_name("jill"),
  29. onclick: move |_| set_name("jill"),
  30. }
  31. button {
  32. class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
  33. onclick: move |_| set_name("jill"),
  34. onclick: move |_| set_name("jill"),
  35. // this is valid
  36. "Jill!",
  37. // this is also valid
  38. {"Jill!"}
  39. }
  40. h1 { "Text", class: "inline-block py-4 px-8 mr-6 leading-none" }
  41. // <h1 class="inline-block py-4 px-8 mr-6 leading-none">
  42. // "Text"
  43. // </h1>
  44. h1 {
  45. div {
  46. h1 {}
  47. h2 {}
  48. Brick {}
  49. p {}
  50. p {
  51. tag: "type",
  52. abc: 123,
  53. enabled: true,
  54. class: "big small wide short",
  55. a { "abcder" },
  56. h2 { "whatsup", class: "abc-123" },
  57. CustomComponent { a: 123, b: 456, key: "1" },
  58. }
  59. div { class: "big small wide short",
  60. div {},
  61. div {},
  62. div {},
  63. div {},
  64. }
  65. }
  66. }
  67. h2 {}
  68. h3 {}
  69. "abcd123"
  70. }
  71. })
  72. }