Skip to content

simsketch/share-button

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

259 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Share Button v2

The social share widget, reborn for 2026 โœจ

Fast ๐Ÿ’จ ย  Lightweight ๐Ÿชถ ย  Beautiful ๐ŸŽจ ย  Zero Dependencies ๐Ÿ“ฆ

Version License Dependencies Size


๐Ÿค” What Is This?

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');

๐Ÿ™ Standing on the Shoulders of Giants

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! ๐Ÿฅ•โค๏ธ

โœจ Features

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

๐Ÿ“ฅ Installation

npm install share-button

Or just grab the files from dist/ and drop them in your project! ๐ŸŽฏ

๐Ÿš€ Quick Start

ESM (recommended) โœ…

import ShareButton from 'share-button';
import 'share-button/dist/share-button.css';

new ShareButton('#share-button');

UMD (script tag) ๐Ÿ“œ

<link rel="stylesheet" href="dist/share-button.css">
<script src="dist/share-button.umd.js"></script>
<script>
  new ShareButton('#share-button');
</script>

HTML ๐Ÿ—๏ธ

<div id="share-button"></div>

That's literally it! ๐ŸŽ‰

โš™๏ธ Options

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
});

๐ŸŒ Supported Networks

Network Key Color
๐Ÿ“˜ Facebook facebook #1877F2
โœ–๏ธ X (Twitter) x #000000
๐Ÿ’ผ LinkedIn linkedin #0A66C2
๐Ÿ“Œ Pinterest pinterest #E60023
๐Ÿค– Reddit reddit #FF4500
๐Ÿ’ฌ WhatsApp whatsapp #25D366
โœˆ๏ธ Telegram telegram #26A5E4
๐Ÿ˜ Mastodon mastodon #6364FF
๐Ÿฆ‹ Bluesky bluesky #0085FF
๐Ÿงต Threads threads #000000
๐Ÿ“ง Email email #777777
๐Ÿ“‹ Copy Link copy #999999

๐ŸŽฎ API

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 configuration

๐ŸŽจ Theming

Make 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 */
}

๐ŸŽญ Built-in Themes

  • default โ€” Clean and professional ๐Ÿ‘”
  • dark โ€” Sleek dark panel background ๐ŸŒ™
  • minimal โ€” Transparent, blends with your design ๐ŸชŸ

๐Ÿ› ๏ธ Development

npm install        # ๐Ÿ“ฆ Install dependencies
npm run dev        # ๐Ÿš€ Start dev server
npm test           # ๐Ÿงช Run tests (42 tests!)
npm run build      # ๐Ÿ—๏ธ Production build

๐Ÿ“Š What Changed from v1

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 ๐Ÿฆ twitter.com โœ–๏ธ x.com
Native Share โŒ โœ… Web Share API
Theming Limited CSS Full CSS custom properties ๐ŸŽจ
Bundle Browserify UMD ESM + UMD ๐Ÿ“ฆ

๐Ÿ“„ License

MIT โ€” do whatever you want with it! ๐ŸŽ‰

๐Ÿ’– Credits

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. โœจ

About

๐Ÿš€ The social share widget, reborn for 2026. Fast, lightweight, zero dependencies. 12 networks including Bluesky, Threads & Mastodon. Originally by Carrot Creative ๐Ÿฅ•

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 79.8%
  • CSS 12.8%
  • HTML 7.4%