Skip to content

Router: Active class if target's URL is within current URL #1241

@DogeDark

Description

@DogeDark

Specific Demand

Add the ability to let the user tell the Link prop to provide the active_class prop if the target's URL is within the current URL.

E.g, if the current URL is either /listings or /listings/random/url/:something, a Link component of the following, will provide the active_class:

Link {
    active_within_route: true, // Probably a better name than this
    active_class: "active",
    target: Route::MyTarget {}
    "my link text"
}

Note:
I imagine this is already possible with one of the router's hooks, however... I'm lazy.

Implement Suggestion

Add a new prop to the Link component that determines whether it should follow the proposed behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    routerRelated to the router implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions