Configure "Link" component via Theme
See original GitHub issueSome 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.
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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
Can I take this issue?
Yeah, in this case, the diff in https://github.com/mui-org/material-ui/issues/21533#issuecomment-647411584 would be interesting. We could use it for Gatsby too cc @hupe1980.