Share Buttons
ProNewShare buttons for a page with labels, supplied counts and an extensible More menu for consumer-owned HTTP(S) share intents. Use inline, grid or floating placement.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| url | stringThe address to share. Defaults to the page the buttons are on. | — |
| title | stringHeadline sent along with the link. Defaults to the page title. | — |
| text | stringLonger text for networks that take a description, and the body of the email. | "" |
| image | stringImage address, used by Pinterest. | "" |
| targets | ShareTarget[]The buttons to show, in order. `native` only appears where the browser has a share sheet. | ["facebook", "x", "linkedin", "whatsapp", "copy"] |
| more | ShareTarget[]Extra targets tucked behind a "More" button. | — |
| customMore | CustomShareTarget[]Additional networks in More, with consumer-supplied share intent URLs; no service connector is installed. | — |
| layout | "inline" | "grid" | "floating"`inline` wraps in a row, `grid` fills two equal columns, `floating` pins a column to the edge of the page. | "inline" |
| variant | "brand" | "mono" | "outline"`brand` fills each button with the network's color, `mono` uses the text color, `outline` draws a ring with a colored mark. | "brand" |
| shape | "square" | "rounded" | "pill" | "rounded" |
| size | "sm" | "md" | "lg"Button height: 28, 36 or 44 pixels. | "md" |
| labels | "none" | "name" | "action"`name` writes "Facebook", `action` writes "Share on Facebook", `none` leaves the icon alone. Floating buttons reveal their label on hover and focus. | layout === "floating" ? "none" : "name" |
| counts | Partial<Record<ShareTarget, number>>Share counts per target, shown inside each button. | — |
| countLayout | "inline" | "above" | "hidden"Keep counts inside buttons, place them above (Facebook box-count style), or omit them visually. Supply counts yourself. | "inline" |
| total | boolean | numberShows the sum of `counts`, or the number you pass, ahead of the buttons. | — |
| side | "left" | "right"Which edge a floating column sticks to. | "left" |
| position | "fixed" | "absolute"`fixed` pins a floating column to the viewport; `absolute` pins it to the nearest positioned ancestor. | "fixed" |
| onShare | (target: ShareTarget, url: string) => voidCalled after a button is used, with the target and the address shared. | — |
| onCustomShare | (id: string, url: string) => void | — |
| className | string | — |
Accessibility
- Built-in networks and safe consumer-supplied More targets are real links; invalid custom URLs show as unavailable rather than navigating.
- Every button has a name such as "Share on Facebook" even when only the icon shows, and visible counts are read as "1.3K shares".
- Copying announces "Link copied to clipboard" or the failure through a polite live region, and the button shows a tick for two seconds.
- The More button opens a scrollable popover that takes focus, closes on Escape and returns focus to the button.
- Floating labels appear on keyboard focus as well as hover; lift and slide are dropped under `prefers-reduced-motion`.