Share Buttons
Social share buttons row for articles.
<div class="flex items-center gap-2">
<span class="text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mr-1">Share</span>
<a href="#" aria-label="Share on X" class="w-9 h-9 rounded-full bg-slate-900 text-white flex items-center justify-center hover:bg-slate-700 hover:-translate-y-0.5 transition-all">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M18.9 2H22l-6.8 7.8L23.2 22h-6.3l-4.9-6.4L6.4 22H3.3l7.3-8.3L1.6 2H8l4.4 5.9L18.9 2zm-1.1 17.8h1.7L7.1 3.9H5.3l12.5 15.9z"/></svg>
</a>
<a href="#" aria-label="Share on Facebook" class="w-9 h-9 rounded-full bg-[#1877F2] text-white flex items-center justify-center hover:opacity-90 hover:-translate-y-0.5 transition-all">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M24 12a12 12 0 10-13.9 11.9v-8.4h-3v-3.5h3V9.4c0-3 1.8-4.7 4.5-4.7 1.3 0 2.7.2 2.7.2v3h-1.5c-1.5 0-2 1-2 1.9V12h3.3l-.5 3.5h-2.8v8.4A12 12 0 0024 12z"/></svg>
</a>
<a href="#" aria-label="Share on LinkedIn" class="w-9 h-9 rounded-full bg-[#0A66C2] text-white flex items-center justify-center hover:opacity-90 hover:-translate-y-0.5 transition-all">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M20.4 20.4h-3.5v-5.6c0-1.3 0-3-1.9-3s-2.1 1.4-2.1 2.9v5.7H9.4V9h3.4v1.6h.1c.5-.9 1.7-1.9 3.4-1.9 3.6 0 4.3 2.4 4.3 5.5v6.2zM5.3 7.4a2 2 0 110-4.1 2 2 0 010 4.1zM7.1 20.4H3.6V9h3.5v11.4z"/></svg>
</a>
<button aria-label="Copy link" class="w-9 h-9 rounded-full bg-slate-100 text-slate-600 flex items-center justify-center hover:bg-slate-300 hover:-translate-y-0.5 transition-all">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"/></svg>
</button>
</div>Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
About this share buttons
Share buttons turn readers into distributors. This row covers the essentials: X, Facebook, LinkedIn, plus a copy-link button. Each is a circular brand-colored button with the platform SVG, lifting slightly on hover for tactile feedback.
The share URLs need the page URL and title injected. For X: twitter.com/intent/tweet?url=...&text=.... For Facebook: facebook.com/sharer/sharer.php?u=.... For LinkedIn: linkedin.com/sharing/share-offsite/?url=.... The copy button uses the Clipboard API.
Place share buttons where sharing happens: article headers, blog footers, product pages. Four options is the sweet spot; a dozen social icons looks desperate and dilutes clicks.
The best distribution channel for content is readers who share it, and sharing is an impulse: the moment someone finishes an article thinking my team needs this, the buttons must be right there. Every scroll past them is a share that didn't happen. Share buttons exist to capture that impulse at its peak with zero friction.
The row is flex items-center gap-2 with a small uppercase Share label. Each network is a w-9 h-9 rounded-full anchor in its brand color (bg-slate-900 for X, bg-[#1877F2] for Facebook) with a white SVG glyph, lifting with hover:-translate-y-0.5 for tactility and carrying an aria-label. The URLs follow each platform's share-intent format with the encoded page URL and title injected: twitter.com/intent/tweet, facebook.com/sharer/sharer.php, linkedin.com/sharing/share-offsite. A copy-link button rounds out the set.
Place the row at the article's top and bottom, where sharing intent peaks. Append UTM parameters so share traffic is measurable. On mobile, prefer the Web Share API (navigator.share), which opens the native sheet with all the user's own apps instead of a fixed set of networks.
The stale-link mistake is hardcoding the share URL at build time, so every article shares the homepage URL or yesterday's link. Shared links that land in the wrong place burn the reader's credibility with their audience. Build share URLs from the live page URL and title at runtime, or inject them per page at render.
Where to use it
- ✓ Blog article headers
- ✓ Product pages
- ✓ Portfolio pieces
- ✓ Documentation footers
Customization tips
Wire each link with the real share URL including encoded page URL and title. Add UTM parameters to track share traffic. On mobile, consider the native Web Share API instead.
Design notes
When to use
Share buttons make sense at the end of content worth spreading, like a blog post or a tool result, where the reader's intent to share is highest. The round icon buttons with a small Share label read as a single unit and stay out of the way of the article itself. Keeping the set to the networks your audience actually uses beats a wall of twenty icons nobody recognizes.
What to avoid
Do not plaster share buttons on every page including checkout and settings screens, it cheapens them and annoys users mid-task. Avoid fake share counts next to the buttons, inflated numbers destroy trust the moment someone checks. And do not open shares in the same tab, losing the article the user wanted to share is a classic frustration.
Accessibility
Each button needs an aria-label naming the network, since an icon alone says nothing to a screen reader. Make sure the tap targets are at least 44 pixels so they are usable on touch screens.
Frequently asked questions
How do social share buttons work?
Each button links to the platform's share URL with your page URL and title as parameters. X uses /intent/tweet, Facebook uses /sharer/sharer.php, LinkedIn uses /sharing/share-offsite/.
How many share buttons should I show?
Three to four: the platforms your audience actually uses, plus copy-link. More options reduce total shares (choice paradox).
Should I use the Web Share API?
On mobile, yes: navigator.share opens the native sheet with all the user's apps. Fall back to manual buttons on desktop.
What is the X share URL format?
Use https://twitter.com/intent/tweet?url=YOUR_URL&text=YOUR_TEXT, with both values passed through encodeURIComponent. This opens the X compose window with your link prefilled and needs no JavaScript or SDK. Add via and hashtags parameters to attribute the share.
How do I add a WhatsApp share button?
Link to https://wa.me/?text= with the encoded message plus page URL as the text parameter. It opens WhatsApp with the message prefilled on both mobile and desktop. Combine the page title and URL in the text so the share reads well in chat.
Do share buttons need Open Graph tags?
Yes. og:title, og:description, and og:image control the preview card that appears when your link is shared on Facebook, X, LinkedIn, and WhatsApp. Without them, networks guess from page content and the preview often looks broken. Test with each network's card validator after adding them.