Skip to content

Configure "Link" component via Theme #21533

@theKashey

Description

@theKashey

Some components (like Buttons) might end up rendering a tags. That's ok, but in usually you cannot use "links" in SPA - they have to be Links, playing nicely with the router of your choice.

It's expected that SPA is using some router, and only one router, as well as expected to use one, and only one Link.
That "right link" should be configurable via Theme.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Long story short - for example button should read value from the theme, not use hardcoded one.

https://github.com/mui-org/material-ui/blob/49eb56aefa997dcbf6fbc0515b7d1fafc19a55dd/packages/material-ui/src/ButtonBase/ButtonBase.js#L264-L266

Examples 🌈

  • no example provided

Motivation 🔦

Every component which might render a link could do it - all you have to provide a right Component instead of default. That's not always handy and working for everyone.

Recently I've seen:

  • Buttons wrapped with Links to make them Links
  • Buttons with onClick={()=>history.push()} to make them play nicely together with router.

All that might be fixed with a single configuration option.

It still would be not possible to use, for example, react-router/Link as a link, due to interface differences, however the wrapper to make Link an a-compatible is just a few lines, and could be provided in MUI documentation as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready to takeHelp wanted. Guidance available. There is a high chance the change will be accepted
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions