Skip to content

[bug] Assets not loading correctly in Dioxus frontend template #908

@Mota-Link

Description

@Mota-Link
> cargo create-tauri-app
✔ Project name · tauri-app
✔ Identifier · com.tauri-app.tauri-app
✔ Choose which language to use for your frontend · Rust - (cargo)
✔ Choose your UI template · Dioxus - (https://dioxuslabs.com/)

Template created! To get started run:
  cd tauri-app
  cargo tauri android init

For Desktop development, run:
  cargo tauri dev

For Android development, run:
  cargo tauri android dev

When generating a Tauri project with the Dioxus frontend template and running cargo tauri dev, the application fails to load assets (CSS, icons, etc.) from the assets/ directory. This results in broken styles and missing icons, as shown in the screenshot below:

Screenshot showing broken assets

The current template uses path strings directly to reference assets. However, per Dioxus’ Styling and Assets documentation, assets should be loaded via the asset!() macro.

Here's a simple diff demonstrating the fix:

+static CSS: Asset = asset!("/assets/styles.css");

 rsx! {
-        link { rel: "stylesheet", href: "styles.css" }
+        link { rel: "stylesheet", href: CSS }
         /* ... */
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions