question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Link] Use the component as a button

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

Summary 💡

Should <Link/> have cursor pointer by default when onClick handler is defined? Sometimes I like to use MuiLink as action toggle, <Link onClick={dosomething}>Edit</Link>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
oliviertassinaricommented, Jul 6, 2021

Tip, the Link component is responsible for the UI display, the <a> component is responsible for the behavior. You can mix the two (button for the UI and link of the behavior or Link for the UI and button for the behavior).

1reaction
oliviertassinaricommented, Jul 6, 2021

We have a demo about using a Link as a button, see: https://material-ui.com/components/links/#accessibility.

<Link
  component="button"
  variant="body2"
  onClick={() => {
    console.info("I'm a button.");
  }}
>
  Button Link
</Link>

and about using a Button as a link:

https://next.material-ui.com/guides/routing/#navigation-components

<Button href="/" variant="contained">
  Link
</Button>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use a Button component as a link in React
To correctly use a Button component as a link in React, override the underlying button HTML tag of the component and turn it...
Read more >
Wrapping a react-router Link in an html button - Stack Overflow
Using an html <button> tag with React Router <Link> component. If you only want an html button tag… <button>label text</button>.
Read more >
How to Use a Button as a Link in React - Coding Beauty
To use a button as a link in React, wrap the button in an anchor ( <a> ) element. Clicking a link button...
Read more >
How to use Button with Link from react-router-dom? #55 - GitHub
Hello @couds and team :) It's not allow in documentation, but still huge important thing — how to use Button component from ...
Read more >
How to Add link to a Button in React Button component
The appearance of the Button can be changed like a link by e-link class using cssClass property and link navigation can be handled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found