Share Button

Overview

A share button that fans out into copy-link and custom share actions.

This action component is intended for interfaces that need a share button that fans out into copy-link and custom share actions, SaaS workflows, and onboarding flows. Its implementation is provided as editable source so the final behavior and styling stay inside your project.

Technologies

React
TypeScript
Tailwind CSS
Motion

Detected package dependencies: framer-motion, lucide-react.

@spectrumui/share-button

Designing calmer micro-interactions

128 likes

Click share — try the copy-link action

Installation

Login to view commandCreate a free account to access the install command

Usage

import { ShareButton } from "@/components/spectrumui/share-button"
<ShareButton
  copyValue="https://ui.spectrumhq.in"
  actions={[
    { icon: <Twitter size={15} />, label: "Share on X", onSelect: () => shareOnX() },
  ]}
/>

API Reference

ShareButton

Renders a round trigger button with aria-expanded and aria-haspopup, and an action row with role="menu". Each entry in actions is a ShareAction: icon: React.ReactNode rendered inside the round button, label: string used as the tooltip and accessible name, and onSelect: () => void fired on click. When copyValue is set, a copy-link button is prepended that writes to the clipboard and flashes an emerald check.

PropTypeDefaultDescription
actionsShareAction[][]Custom actions fanned out after the built-in copy action
copyValuestring-URL or text for the built-in copy-link first action; omit to hide it
direction"left" | "right""right"Side the actions fan out toward
size"sm" | "md" | "lg""md"Visual size of the trigger; actions are one step smaller
labelstring"Share"Accessible name of the trigger
closeOnSelectbooleantrueCollapse the row shortly after a custom action is selected
classNamestring-Additional classes merged onto the root element

Examples

Direction and sizes

Fans out to the left, plus the three trigger sizes

Use cases

  • interfaces that need a share button that fans out into copy-link and custom share actions
  • SaaS workflows
  • onboarding flows

Features

  • Copy-paste source that remains in your repository
  • TypeScript source included with the component
  • Tailwind CSS classes editable in the component source
  • Animation implemented with Motion
  • Responsive Tailwind variants present in the source
  • Reduced-motion handling present in the source

Accessibility

  • The source includes ARIA attributes or roles; preserve them when customizing the component.
  • The source includes keyboard event handling; verify it alongside pointer behavior.
  • The source checks reduced-motion preferences or includes motion-reduce styles.
  • Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.

Customization

  • Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
  • Use the documented className surface for local layout adjustments, then edit the source for structural changes.
  • Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.

Topic guides

See how this component fits into broader interface patterns, implementation decisions, and working examples.

Share Button FAQ

Is Share Button free to use in commercial projects?

Yes. The public Share Button source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.

How do I install Share Button?

Run npx shadcn@latest add @spectrumui/share-button. The page also exposes the source for manual installation.

Does Share Button require Motion?

Yes. Motion usage was detected in the documented source or registry dependencies for Share Button.

Does Share Button use shadcn/ui or Radix UI?

No shadcn/ui or Radix UI dependency was detected in the documented Share Button source.

Can I use Share Button in Next.js?

The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.

What accessibility checks should I run for Share Button?

The source includes ARIA markup, keyboard handlers, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.