JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 221
  • Score
    100M100P100Q93563F
  • License MIT

A complete and simple to use share menu.

Package Exports

  • share-menu

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (share-menu) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

<share-menu>

Published on webcomponents.org GitHub release

Demo and API docs

A complete and simple to use share menu that uses Web Share API when possible, with a fallback to a nice share menu that tries to emulate the experience of the native one.

Features

  • Incredibly simple to use. Just set the title, text, url and via properties and call the share() method to make the magic happen.
  • Customizable. It offers a great material design UI by default, but it is also designed to be customizable through CSS custom properties. However, keep in mind that CSS mixins have been deprecated, so you won't be able to customize it a lot until the new standard makes its way into the browsers.
  • Compatible with any major browser. The Web Share API is still quite young, but the fallback dialog works on any browser supporting Custom Elements (directly or through a polyfill). Unlike the native share menu, the fallback will also work on desktop browsers and insecure contexts, so you will be able to offer a much more coherent experience to your users.

Installation

npm i share-menu
# or
yarn add share-menu

Without npm/yarn

If you don't use npm or yarn, an IIFE (Immediately Invoked Function Expression) version of the element is also provided. The IIFE version of the element can also be used if you're still on Bower (e.g. if you're using Polymer < 3). To use it, just use the unpkg CDN:

<script src="https://unpkg.com/share-menu@3.0.1/social-icons.iife.js"></script>
<script src="https://unpkg.com/share-menu@3.0.1/share-menu.iife.js"></script>

Usage

Basic usage

<share-menu id="shareMenu" title="Ohai!" text="Just a test" url="https://www.example.com/"></share-menu>

<button onclick="shareMenu.share()">Share!</button>

All the properties set

<share-menu
  title="Awesome!"
  text="More customized share menu"
  url="https://www.example.com/"
  via="Dabolus"
  dialog-title="Share now!"
  is-image="auto"
  no-backdrop>
</share-menu>

Supported socials (in the fallback dialog)

Here you can see the list of the supported socials, as well as the limitations that each one gives:

  • Baidu - URL and title only
  • Blogger
  • Buffer - URL and title only
  • Copy to clipboard
  • Delicious - URL and title only
  • Digg - URL and title only
  • Douban - URL and title only
  • Email
  • Evernote - URL only
  • Facebook - URL only if not using Facebook JS SDK
  • FlipBoard - URL and title only
  • Google+ - URL only
  • Instapaper
  • Line - URL only
  • LinkedIn
  • LiveJournal
  • Myspace
  • Odnoklassniki (OK.ru) - URL and title only
  • Pinterest - Will only be visible if the URL is an image. Look for the isImage parameter on the API docs for more info
  • Pocket - URL only
  • Print - Only prints the page at the given URL
  • QZone - URL only
  • Reddit - Shares an URL if there is no text provided, otherwise a text with the URL appended at the end will be shared.
  • RenRen - Currently disabled because it does not seem to work
  • Skype - URL only
  • SMS
  • StumbleUpon - URL and title only
  • Telegram
  • Translate - Only translates the page at the given URL
  • Tumblr
  • Twitter
  • Viber
  • VKontakte - URL only
  • Weibo
  • WhatsApp
  • WordPress
  • Xing - URL only
  • Yahoo

The via parameter will only be used by Delicious, LinkedIn and Twitter.

Icons

The icons used by the component are just simple SVGs, so you can use them anywhere in your app simply by importing social-icons.js located in this package.

Styling

The following custom properties and mixins are available for styling:

Custom property Description Default
--backdrop-color The color of the backdrop #000
--background-color The background color of the fallback dialog #fff
--title-color The color of the title of the fallback dialog rgba(0, 0, 0, .6)
--ripple-color The color of the ripple of the fallback dialog #000
--labels-color The color of the social labels of the fallback dialog rgba(0, 0, 0, .87)