
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@tsaddict/react-social-share
Advanced tools
Lightweight React social share buttons with Tailwind animations and React Icons.
A lightweight, modern React component library for social media sharing with beautiful Tailwind CSS animations and React Icons integration.
npm install @tsaddict/react-social-share
Since this package uses Tailwind CSS utility classes, you need to have Tailwind CSS configured in your project:
Install Tailwind CSS:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Configure your tailwind.config.js:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
"./node_modules/@tsaddict/react-social-share/**/*.{js,jsx,ts,tsx}"
],
theme: {
extend: {},
},
plugins: [],
}
Import Tailwind in your CSS:
@tailwind base;
@tailwind components;
@tailwind utilities;
Install Tailwind CSS v4:
npm install -D tailwindcss@next
Create tailwind.config.ts:
import type { Config } from 'tailwindcss'
export default {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
"./node_modules/@tsaddict/react-social-share/**/*.{js,jsx,ts,tsx}"
],
} satisfies Config
Import Tailwind in your CSS:
@import "tailwindcss";
Note: Tailwind v4 is still in development. For production apps, we recommend using v3.
This package requires the following peer dependencies:
{
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-icons": ">=4.0.0",
"tailwindcss": ">=3.0.0 || ^4.0.0-alpha"
}
Important: You must have Tailwind CSS configured in your project for the styling to work. The components use Tailwind utility classes that need to be processed by Tailwind CSS.
Make sure you have these installed in your project.
import { SocialButton, SocialShareGroup } from "@tsaddict/react-social-share";
function App() {
return (
<div>
{/* Single social share button */}
<SocialButton
platform="twitter"
url="https://example.com"
text="Check out this amazing article!"
/>
{/* Group of social share buttons */}
<SocialShareGroup
url="https://example.com"
text="Amazing content to share!"
/>
</div>
);
}
Individual social media share button component.
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
platform | Platform | ✅ | - | Social media platform to share to |
url | string | ✅ | - | URL to share |
text | string | ❌ | - | Optional text to include with the share |
label | string | ❌ | Platform default | Custom label text |
className | string | ❌ | "" | Additional CSS classes for styling |
iconClassName | string | ❌ | "" | Additional CSS classes for the icon |
type Platform =
| "facebook"
| "X"
| "linkedin"
| "whatsapp"
| "telegram"
| "reddit"
| "email"
| "messenger"
| "discord";
<SocialButton
platform="linkedin"
url="https://mycompany.com/careers"
text="We're hiring! Check out our open positions."
label="Share on LinkedIn"
className="text-sm px-6 py-3"
iconClassName="text-xl"
/>
Container component that renders multiple social share buttons.
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | ✅ | - | URL to share |
text | string | ❌ | - | Optional text to include with shares |
platforms | Platform[] | ❌ | All platforms | Specific platforms to show |
wrapClassName | string | ❌ | "flex flex-wrap items-center gap-3" | Container CSS classes |
buttonClassName | string | ❌ | - | CSS classes applied to all buttons |
iconClassName | string | ❌ | - | CSS classes applied to all icons |
labels | Partial<Record<Platform, string>> | ❌ | {} | Custom labels per platform |
<SocialShareGroup
url="https://myblog.com/post-123"
text="Amazing blog post about React!"
platforms={["twitter", "linkedin", "reddit"]}
wrapClassName="flex flex-col gap-2"
buttonClassName="w-full justify-center"
labels={{
twitter: "Tweet this",
linkedin: "Share on LinkedIn",
reddit: "Post to Reddit",
}}
/>
The components use Tailwind CSS classes and can be easily customized:
// Custom button styling
<SocialButton
platform="facebook"
url="https://example.com"
className="bg-purple-600 hover:bg-purple-700 rounded-full px-6 py-3"
/>
// Custom group layout
<SocialShareGroup
url="https://example.com"
wrapClassName="grid grid-cols-2 md:grid-cols-3 gap-4"
buttonClassName="text-sm font-bold"
/>
Each platform has its brand colors by default:
bg-blue-600)bg-black)bg-blue-700)bg-green-500)bg-sky-400)bg-orange-500)bg-gray-500)bg-blue-500)bg-purple-500)The components include smooth animations:
hover:scale-110)active:scale-95)transition-all duration-300)You can override the default icons with custom ones:
import { FaCustomIcon } from 'react-icons/fa';
<SocialButton
platform="facebook"
url="https://example.com"
icon={FaCustomIcon}
iconProps={{ size: 24, color: "white" }}
/>
function ShareSection({ article, user }) {
const platforms = user.isPremium
? ["facebook", "X", "linkedin", "whatsapp", "telegram", "reddit", "email", "messenger", "discord"]
: ["facebook", "X"];
return (
<SocialShareGroup
url={article.url}
text={article.title}
platforms={platforms}
/>
);
}
function ShareButtons({ post }) {
const labels = {
X: `Share "${post.title}" on X`,
linkedin: `Share "${post.title}" on LinkedIn`,
facebook: `Share "${post.title}" on Facebook`,
email: `Email "${post.title}" to friends`,
messenger: `Send "${post.title}" via Messenger`
};
return <SocialShareGroup url={post.url} text={post.title} labels={labels} />;
}
import { getShareUrl } from "@tsaddict/react-social-share";
function CustomShareButton({ platform, url, text }) {
const shareUrl = getShareUrl(platform, url, text);
const handleClick = () => {
// Custom logic before sharing
analytics.track("share_clicked", { platform, url });
window.open(shareUrl, "_blank");
};
return <button onClick={handleClick}>Share on {platform}</button>;
}
The components are fully responsive and mobile-optimized:
wa.me for mobile and desktop compatibilityThe components are designed to be easily testable:
import { render, screen } from "@testing-library/react";
import { SocialButton } from "@tsaddict/react-social-share";
test("renders social button with correct platform", () => {
render(<SocialButton platform="X" url="https://example.com" />);
expect(screen.getByLabelText("Share on X")).toBeInTheDocument();
});
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions:
icon and iconProps propsdata-testid attributesfunction BlogPost({ post }) {
return (
<article>
<h1>{post.title}</h1>
<p>{post.excerpt}</p>
<div className="mt-8">
<h3>Share this post:</h3>
<SocialShareGroup
url={post.url}
text={post.title}
platforms={["twitter", "linkedin", "facebook"]}
wrapClassName="flex gap-3 mt-4"
/>
</div>
</article>
);
}
function ProductPage({ product }) {
return (
<div>
<h1>{product.name}</h1>
<p>{product.description}</p>
<SocialShareGroup
url={product.url}
text={`Check out ${product.name} - ${product.description}`}
labels={{
twitter: "Tweet this product",
facebook: "Share on Facebook",
whatsapp: "Share via WhatsApp",
}}
buttonClassName="bg-gray-800 hover:bg-gray-900"
/>
</div>
);
}
function NewsletterSignup() {
return (
<div className="bg-blue-50 p-6 rounded-lg">
<h3>Stay updated!</h3>
<p>Share our newsletter with your network:</p>
<SocialShareGroup
url="https://mycompany.com/newsletter"
text="Subscribe to our amazing newsletter!"
platforms={["twitter", "linkedin"]}
wrapClassName="flex gap-2 mt-4"
buttonClassName="text-sm px-3 py-2"
/>
</div>
);
}
Built with ❤️ using React, TypeScript, and Tailwind CSS
FAQs
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.