optional_props.rs 624 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //! Example: README.md showcase
  2. //!
  3. //! The example from the README.md.
  4. use dioxus::prelude::*;
  5. fn main() {
  6. dioxus::desktop::launch(app);
  7. }
  8. fn app(cx: Scope) -> Element {
  9. cx.render(rsx! {
  10. Button {
  11. a: "asd".to_string(),
  12. c: Some("asd".to_string()),
  13. d: "asd".to_string(),
  14. }
  15. })
  16. }
  17. #[derive(Props, PartialEq)]
  18. struct ButtonProps {
  19. a: String,
  20. #[props(default)]
  21. b: Option<String>,
  22. #[props(default)]
  23. c: Option<String>,
  24. #[props(default, strip_option)]
  25. d: Option<String>,
  26. }
  27. fn Button(cx: Scope<ButtonProps>) -> Element {
  28. todo!()
  29. }