tailwind.rs 4.5 KB

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