tailwind.rs 4.9 KB

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