Updated
Share Menu
Share
Copy Link
Download
Print
Customize
Duration0.50s
Bounce0.00
Blur4px
Installation
npx shadcn@latest add https://uibrik.com/r/share-menu.jsonInstall the packages
npm install @tabler/icons-react motion react-use-measureSet up squircle corners
Needs
@squircle/core,@squircle/tailwindcssand a few lines of CSS. See squircle setup.Copy the source into your project
components/uibrik/share-menu/share-menu.tsx"use client"; import { IconDownload, IconLink, IconPrinter } from "@tabler/icons-react"; import React, { useState } from "react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import useMeasure from "react-use-measure"; // Icons: Tabler Icons (MIT). const DownloadIcon = ({ className }: { className?: string }) => ( <IconDownload aria-hidden="true" size={18} stroke={1.75} className={className} /> ); const LinkIcon = ({ className }: { className?: string }) => ( <IconLink aria-hidden="true" size={18} stroke={1.75} className={className} /> ); const PrintIcon = ({ className }: { className?: string }) => ( <IconPrinter aria-hidden="true" size={18} stroke={1.75} className={className} /> ); // Round up to an even integer so that centering (a 50% split of the box) always // lands on a whole pixel instead of a half pixel. const toEven = (value: number) => Math.ceil(value / 2) * 2;
Adds the files to
components/uibrik/share-menu and installs @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/share-menu.Usage
import { ShareMenu } from "@/components/uibrik/share-menu/share-menu";const options = [ { label: "Copy Link", Icon: LinkIcon }, { label: "Download", Icon: DownloadIcon }, // …1 more];<ShareMenu label="Share" duration={0.5} bounce={0} blur={4} options={options}/>Where to use Share Menu
Sharing posts and products
A button flipping open into a pill of options keeps share targets one tap away.
Pairs with Copy Button
Blog social links
Resizing to fit lets the pill hold two or six networks.
Referral flows
A compact share menu suits invite and referral prompts.
Pairs with Invite Members
Props
ShareMenu- label
- Type string
- "Share"
- Text on the closed pill.
- duration
- Type number
- 0.5
- How long the pill takes to resize.
- bounce
- Type number
- 0
- Spring bounce of the resize.
- blur
- Type number
- 4
- Blur as the label and options swap.
- options
- Type ShareOption[]
- Copy link, Download, Print
- Rows in the open menu: label, Icon, onSelect.