Skip to content

Link component: active_class is sometimes not applied (tailwind) #5318

@NiklasVousten

Description

@NiklasVousten

Problem

Sometimes the tailwind classes in active_class do not get applied. I assume this is dependent on the order the tailwind classes, and not how it is in the html/rsx.

Steps To Reproduce

Might not result in the "failed" style, due to "correct" css order.

Link {
    class: "text-gray-700 dark:text-gray-400",
    active_class: "text-red-700 dark:text-brand-400",
    to: Route::Home,
    "Home"
}

Expected behavior

A solution might be to add a ! in front of the active tailwind classes.

Link {
    class: "text-gray-700 dark:text-gray-400",
    active_class: "!text-red-700 dark:!text-brand-400",
    to: Route::Home,
    "Home"
}

Another option might be to add an inactive_class to the Link component. Such that class is always active. And depending on the route, active_class or inactive_class are added.

Environment:

  • Dioxus version: 0.7.1
  • Rust version: 1.93.0
  • OS info: bazzite-43.20260212
  • App platform: web

Questionnaire

I would like to fix and I have a possible solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions