tailwind.rs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #![allow(non_snake_case)]
  2. //! Example: Basic Tailwind usage
  3. //!
  4. //! This example shows how an app might be styled with TailwindCSS.
  5. //!
  6. //! To minify your tailwind bundle, currently you need to use npm. Follow these instructions:
  7. //!
  8. //! https://dev.to/arctic_hen7/how-to-set-up-tailwind-css-with-yew-and-trunk-il9
  9. use dioxus::prelude::*;
  10. use dioxus_desktop::Config;
  11. fn main() {
  12. dioxus_desktop::launch_cfg(
  13. app,
  14. Config::new()
  15. .with_custom_head("<script src=\"https://cdn.tailwindcss.com\"></script>".to_string()),
  16. );
  17. }
  18. pub fn app(cx: Scope) -> Element {
  19. cx.render(rsx!(
  20. div {
  21. header { class: "text-gray-400 bg-gray-900 body-font",
  22. div { class: "container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center",
  23. a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
  24. StacksIcon {}
  25. span { class: "ml-3 text-xl", "Hello Dioxus!"}
  26. }
  27. nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center",
  28. a { class: "mr-5 hover:text-white", "First Link"}
  29. a { class: "mr-5 hover:text-white", "Second Link"}
  30. a { class: "mr-5 hover:text-white", "Third Link"}
  31. a { class: "mr-5 hover:text-white", "Fourth Link"}
  32. }
  33. button {
  34. class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
  35. "Button"
  36. RightArrowIcon {}
  37. }
  38. }
  39. }
  40. section { class: "text-gray-400 bg-gray-900 body-font",
  41. div { class: "container mx-auto flex px-5 py-24 md:flex-row flex-col items-center",
  42. div { class: "lg:flex-grow md:w-1/2 lg:pr-24 md:pr-16 flex flex-col md:items-start md:text-left mb-16 md:mb-0 items-center text-center",
  43. h1 { class: "title-font sm:text-4xl text-3xl mb-4 font-medium text-white",
  44. br { class: "hidden lg:inline-block" }
  45. "Dioxus Sneak Peek"
  46. }
  47. p {
  48. class: "mb-8 leading-relaxed",
  49. "Dioxus is a new UI framework that makes it easy and simple to write cross-platform apps using web
  50. technologies! It is functional, fast, and portable. Dioxus can run on the web, on the desktop, and
  51. on mobile and embedded platforms."
  52. }
  53. div { class: "flex justify-center",
  54. button {
  55. class: "inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg",
  56. "Learn more"
  57. }
  58. button {
  59. class: "ml-4 inline-flex text-gray-400 bg-gray-800 border-0 py-2 px-6 focus:outline-none hover:bg-gray-700 hover:text-white rounded text-lg",
  60. "Build an app"
  61. }
  62. }
  63. }
  64. div { class: "lg:max-w-lg lg:w-full md:w-1/2 w-5/6",
  65. img {
  66. class: "object-cover object-center rounded",
  67. src: "https://i.imgur.com/oK6BLtw.png",
  68. referrerpolicy:"no-referrer",
  69. alt: "hero",
  70. }
  71. }
  72. }
  73. }
  74. }
  75. ))
  76. }
  77. pub fn StacksIcon(cx: Scope) -> Element {
  78. cx.render(rsx!(
  79. svg {
  80. fill: "none",
  81. stroke: "currentColor",
  82. stroke_linecap: "round",
  83. stroke_linejoin: "round",
  84. stroke_width: "2",
  85. class: "w-10 h-10 text-white p-2 bg-indigo-500 rounded-full",
  86. view_box: "0 0 24 24",
  87. path { d: "M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"}
  88. }
  89. ))
  90. }
  91. pub fn RightArrowIcon(cx: Scope) -> Element {
  92. cx.render(rsx!(
  93. svg {
  94. fill: "none",
  95. stroke: "currentColor",
  96. stroke_linecap: "round",
  97. stroke_linejoin: "round",
  98. stroke_width: "2",
  99. class: "w-4 h-4 ml-1",
  100. view_box: "0 0 24 24",
  101. path { d: "M5 12h14M12 5l7 7-7 7"}
  102. }
  103. ))
  104. }