[Link] disabled prop & interaction behaviour
See original GitHub issueBug report
Describe the bug
The Link
component has default visuals for _disabled
. However, the typings do not reflect that and interactions are not actually prevented.
Expected behavior
I’d expect passing disabled
to Link
to prevent interactions and TypeScript not having issues with that.
- add
disabled?: boolean
toLinkProps
- add documentation for it via JSDoc
- adjust the props in the docs
- consider adding an example to the Link docs too
- all interactions (click, touch) have
event.preventDefault()
ifdisabled
, otherwise executeprops.onClick
if present.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How to Disable Links | CSS-Tricks
There is a problem though: there is no real way to disable an <a> link (with a valid href attribute) in HTML. Not...
Read more >How to Disable a Link using Only CSS
Answer: Use the CSS pointer-events Property. You can simply use the CSS pointer-events property to disable a link. The none value of this...
Read more >How to disable a link using only CSS - Stack Overflow
I have a class called current-page and want links with this class to be disabled so that no action occurs when they are...
Read more >ARIA: link role - Accessibility - MDN Web Docs
The link role is used to identify an element that creates a hyperlink to a resource that is in the application or external....
Read more >Links - Material UI - MUI
The Link component allows you to easily customize anchor elements with your theme colors ... The underline prop can be used to set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@segunadebayo Thank you for your feedback. I would like to add the following:
Link
component becomes indeed non-interactive under the hood if you omit thehref
attribute, but what about the styling? TheLink
component still gives me (wrong) feedback (hover state) when nohref
is provided. Shouldn’t we apply adisabled
styling when there’s nohref
?Hey guys,
Removing the
isDisabled
from the link component was intentional. Links are not buttons and shouldn’t havedisabled
in them. We want to be careful not to invent anti-patterns.The way to make a link non-interactive is to omit the
href
attribute.Permit me to close this as well as the PR.
Thanks guys 💖