1.0.0 • Published 5 years ago

react-sharingbuttons v1.0.0

Weekly downloads
421
License
MIT
Repository
github
Last release
5 years ago

react-sharingbuttons

Lightweight social sharing buttons for React. No tracking. Just fun. Heavily inspired by sharingbuttons.io

Demo & Docs:

https://caspg.github.io/react-sharingbuttons

Installation

  yarn add react-sharingbuttons

or alternatively:

npm install --save react-sharingbuttons

Usage

import { Facebook, Twitter } from 'react-sharingbuttons'

NOTE If you care about your bundle size, you can import each button separately.

import Facebook from 'react-sharingbuttons/dist/buttons/Facebook'
import Twitter from 'react-sharingbuttons/dist/buttons/Twitter'

Import predefined css:

import 'react-sharingbuttons/dist/main.css'
const sharingButtons = () => {
  const url = 'https://github.com/caspg/react-sharingbuttons'
  const shareText = 'Check this site!'

  return (
    <div>
      <Facebook url={url} />
      <Twitter url={url} shareText={shareText} />
    </div>
  )
}

See the example

Overriding styles

You can customize buttons further to meet your needs. For example, following html will be rendered for Twitter button:

<a href="https://your.website" class="react-sharing-button__link react-sharing-button--twitter">
  <svg class="react-sharing-button__icon">...</svg>
  <span class="react-sharing-button__text">Share me</span>
</a>

Available buttons and its props

common props:

  • text - text which is displayed inside button, default to button name.
  • onClick - onClick event passed to a tag.

button specific props:

Emailtext, url, subject
Facebooktext, url
Googletext, url
Pinteresttext, url, shareText (a pin description), mediaSrc
Reddittext, url
Twittertext, url, shareText (a tweet text),
Tumblrtext, url, title, caption, content
1.0.0

5 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago