couetilc / react-social-icons

svg social icons in react
https://react-social-icons.com
MIT License
414 stars 140 forks source link

docs: target _blank #128

Closed Vandivier closed 1 year ago

Vandivier commented 2 years ago

I naively tried target="_blank" and it worked fine although i didn't see that was possible based on demo site or README

great library!

rajviahmedtamim commented 1 year ago

can I see demo example how you solve it?

Vandivier commented 1 year ago

@rajviahmedtamim consider this excerpt from my open source app not-johns-linktree:

import { FunctionComponent } from "react";
import { SocialIcon, SocialIconProps } from "react-social-icons";

import styles from "./Socials.module.css";

const StyledSocialIcon: FunctionComponent<SocialIconProps> = (props) => (
  <SocialIcon
    {...props}
    style={{ height: "2rem", margin: ".25rem", width: "2rem" }}
  />
);

export const Socials = () => (
  <ul className={styles["social-list-wrapper"]}>
    <li>
      <StyledSocialIcon
        url="https://twitter.com/johnvandivier"
        target="_blank"
      />
    </li>
    <li>
      <StyledSocialIcon
        url="https://www.youtube.com/c/JohnVandivier"
        target="_blank"
      />
    </li>
    <li>
      <StyledSocialIcon url="mailto:john@ladderly.io" target="_blank" />
    </li>
  </ul>
);
couetilc commented 1 year ago

thank you @Vandivier, this question is now addressed in the README: https://github.com/couetilc/react-social-icons#how-do-i-open-the-link-in-a-new-tab-when-the-icon-is-clicked