tailwind.rs 4.5 KB

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