This repository was archived by the owner on Jan 23, 2024. It is now read-only.
Replies: 2 comments
-
Using an IconButton instead of an Icon improves the accessibility of your application :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi. if you use IconButton instead of Icon itself, you will avoid different layers which an icon tag could have. The IconButton component is a derivative to Button component and will accept all props. Plus, it has some pre-defined styles which you can override easily. If you want to pass onClick to an icon, set the prop "variant" to "unstyled" for IconButton. like this:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was reading about Icons in ChakraUI and I came across this warning:
"🚨 Avoid passing onClick handlers to icon components. If you need a clickable icon, use the IconButton instead."
Out of curiosity, I wanted to ask: Is there a particular reason why the onClick attribute should be avoided on the Icon element?
Thank you for your response in advance🙏
Beta Was this translation helpful? Give feedback.
All reactions