I have this Icon from material UI, I wish to make it clickable and open a new window to www.linkedin.com
should I use href="Linkedin.com" ? or add onClick ? I wish it to open a new tab/window aswell
I have this Icon from material UI, I wish to make it clickable and open a new window to www.linkedin.com
should I use href="Linkedin.com" ? or add onClick ? I wish it to open a new tab/window aswell
This should do using Material-UI Icons:
import LinkedInIcon from '@material-ui/icons/LinkedIn';
import IconButton from '@material-ui/core/IconButton';
<IconButton aria-label="Linkedin.com" onClick={() => window.open('https://www.Linkedin.com')}>
<LinkedInIcon fontSize="large" />
</IconButton>
To open a new page:
onClick={() => window.open(newPageUrl, "_blank")}
To open on the same one:
onClick={() => window.location.replace(newPageUrl)}
<IconButton href="https://linkedin.com" />
should work in most use cases. see: github.com/mui-org/material-ui/issues/6243 –
Mastodon you can use href
on Button
or IconButton
import { Icon, IconButton } from "@mui/material";
<IconButton href={app.url} aria-label="launch" color="primary" target="_blank">
<Icon baseClassName="material-icons" >launch</Icon>
</IconButton>
there is two way which can help you
© 2022 - 2025 — McMap. All rights reserved.
onClick
make use oftarget=_blank
attribute for showing a new tab like https://mcmap.net/q/166412/-maintaining-href-quot-open-in-new-tab-quot-with-an-onclick-handler-in-react/4636715 – Moulding<a>
. – Scathing