The social share widget, reborn for 2026 โจ
Fast ๐จ ย Lightweight ๐ชถ ย Beautiful ๐จ ย Zero Dependencies ๐ฆ
A drop-in social sharing widget that just works. No iframes. No third-party scripts. No bloat. Just a clean, beautiful share button that opens a panel of social networks.
One line of code. That's it. ๐
new ShareButton('#share');This project is a full rewrite of the legendary share-button originally built by the incredible team at Carrot Creative ๐ฅ
The original was ahead of its time โ fast, lightweight, and beautifully designed when every other share widget was loading megabytes of third-party garbage onto your page. Jeff Escalante, Tom Milewski, Henry Snopek, Patrick Bacon-Blaber, and the whole Carrot crew absolutely nailed it. ๐ฏ
But the web has changed a lot since then. Google+ is gone โ ๏ธ, Twitter became X ๐, new platforms like Bluesky and Threads have emerged ๐ฑ, and build tools have evolved from Gulp + Browserify to modern bundlers like Vite โก
So we gave it a fresh coat of paint for 2026. Same spirit, new everything. Thank you Carrot โ we couldn't have done this without your original vision! ๐ฅโค๏ธ
| Feature | Details |
|---|---|
| ๐ 12 Social Networks | Facebook, X, LinkedIn, Pinterest, Reddit, WhatsApp, Telegram, Mastodon, Bluesky, Threads, Email, Copy Link |
| ๐ฑ Web Share API | Uses native share sheet on supported devices automatically |
| ๐จ Themeable | CSS custom properties โ customize everything |
| ๐ญ 3 Built-in Themes | default, dark, minimal |
| ๐ฆ Zero Dependencies | Vanilla JS + CSS. That's it. |
| โก Tiny Bundle | ~14KB JS + ~3KB CSS (uncompressed) |
| ๐ง ESM + UMD | Works everywhere โ import, require, or script tag |
| โฟ Accessible | ARIA labels on all buttons |
| ๐งช Fully Tested | 42 tests with Vitest |
npm install share-buttonOr just grab the files from dist/ and drop them in your project! ๐ฏ
import ShareButton from 'share-button';
import 'share-button/dist/share-button.css';
new ShareButton('#share-button');<link rel="stylesheet" href="dist/share-button.css">
<script src="dist/share-button.umd.js"></script>
<script>
new ShareButton('#share-button');
</script><div id="share-button"></div>That's literally it! ๐
new ShareButton('#share-button', {
url: 'https://example.com', // ๐ URL to share (default: current page)
title: 'Check this out', // ๐ Share title (default: og:title or page title)
description: 'A great article', // ๐ Share description (default: meta description)
image: 'https://example.com/img', // ๐ผ๏ธ Image URL for Pinterest
networks: ['facebook', 'x', 'linkedin', 'reddit', 'email'], // ๐ก Networks to show
buttonText: 'Share', // ๐ท๏ธ Button label
flyout: 'top', // ๐ Panel position: 'top', 'bottom', 'left', 'right'
theme: 'default', // ๐จ Theme: 'default', 'dark', 'minimal'
useWebShareApi: true, // ๐ฑ Use native share on supported devices
});const share = new ShareButton('#el');
share.open(); // ๐ Open the share panel
share.close(); // ๐ Close the share panel
share.toggle(); // ๐ Toggle the share panel
share.destroy(); // ๐ฅ Remove from DOM and clean up
share.config; // โ๏ธ Access current configurationMake it yours with CSS custom properties:
:root {
--sb-button-bg: #333; /* ๐จ Button background */
--sb-button-color: #fff; /* โ๏ธ Button text color */
--sb-button-radius: 8px; /* ๐ Button border radius */
--sb-icon-size: 48px; /* ๐ Network icon size */
--sb-flyout-radius: 12px; /* ๐ฒ Panel border radius */
--sb-flyout-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); /* ๐ Panel shadow */
}defaultโ Clean and professional ๐darkโ Sleek dark panel background ๐minimalโ Transparent, blends with your design ๐ช
npm install # ๐ฆ Install dependencies
npm run dev # ๐ Start dev server
npm test # ๐งช Run tests (42 tests!)
npm run build # ๐๏ธ Production build| v1 (Carrot) ๐ฅ | v2 (2026) ๐ | |
|---|---|---|
| Build | Gulp + Browserify | Vite โก |
| CSS | Stylus | Plain CSS with custom properties |
| Tests | Pioneer + PhantomJS ๐ป | Vitest + jsdom ๐งช |
| Networks | 8 (inc. Google+ โ ๏ธ) | 12 (inc. Bluesky, Threads, Mastodon ๐ฑ) |
| ๐ฆ twitter.com | โ๏ธ x.com | |
| Native Share | โ | โ Web Share API |
| Theming | Limited CSS | Full CSS custom properties ๐จ |
| Bundle | Browserify UMD | ESM + UMD ๐ฆ |
MIT โ do whatever you want with it! ๐
Built with love on top of the original share-button by Carrot Creative ๐ฅ
"Simple, light, flexible, and good-looking" โ the original tagline that still holds true. We just made it shinier. โจ










