DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.44k stars 826 forks source link

Update TailwindCSS Example Project #2402

Closed DickyChengg closed 6 months ago

DickyChengg commented 6 months ago

Contribute

Is there something that I can do to update the Tailwind Example Project?

I'm having hard time to figure out how to include the tailwind css even I had followed this example. But it turns out there is something missing. (Or maybe I miss something else πŸ€”)

I have to add the css_url to the virtual_dom config on launch to make it worked as expected:

let css_url = format!(
  r#"<link rel="stylesheet" href="{}">"#,
  mg!(file("public/tailwind.css"))
);
let config = dioxus_desktop::Config::new()
  .with_custom_head(css_url);

let dom = VirtualDom::new(app);
dioxus_desktop::launch::launch_virtual_dom(dom, config);

I haven't tried to configure it on mobile apps because I'm still a lil bit confuse on how to setup the Cargo and checking the platform. ps: I'm really new to Rust πŸ˜….

Result:

Screenshot 2024-05-10 at 15 40 33

I hope the next person can save a lot of time to configure TailwindCss plus they don't have to explain everything to ChatGP, Codiumate and Bard on "how to fix this" kekw.

Thanks to Bard.

DogeDark commented 6 months ago

The manganis _STYLE line that includes the stylesheet should be linking it, however, it requires the app to be built with the Dioxus CLI to work. Perhaps you weren't running it with the CLI? If not, you can install it with cargo install dioxus-cli

DickyChengg commented 6 months ago

Haa I see, I missed this one. Thanks for the explanation, I'm using VS Code terminal and almost give up to resolve this issue πŸ™ˆ