tailwind.rs 5.0 KB

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