1.4.3 • Published 1 year ago

react-contact-buttons v1.4.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

react-contact-buttons

Contact buttons to copy to clipboard, open in Whatsapp, Telegram, Skype, call and send sms to a number and send a mail with Gmail or Outlook.

Installation and Usage

Install it via yarn or npm

yarn add react-contact-buttons

or

npm install react-contact-buttons

Then import the buttons, add component, props and children to use them:

import React from "react";
import { 
    CopyToClipboard, 
    OpenWhatsApp, 
    OpenTelegram, 
    OpenSkypeSoftware, 
    OpenGmail, 
    OpenOutlook, 
    CallTo, 
    SmsTo 
} from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <ComponentName props > children </ComponentName>
    </div>
);

Props

You can use and customize these buttons using the below props, out of which "tel", "to", "tUser" and "sUser" are the only required prop, the rest are optional.

NameTypeDefaultDescription
telStringnoneThe telephone number to be used (Only CopyToClipboard, OpenWhatsApp, CallTo and SmsTo).
msgStringnoneThe message to be added automatically and sent (Only OpenWhatsApp and SmsTo).
tUserStringnoneThe user phone number or username to be used (Only OpenTelegram).
sUserStringnoneThe user to be used (Only OpenSkypeSoftware).
actionStringchatChoose action with these options: "chat", "call" or "videoCall" (Only OpenSkypeSoftware).
toStringnoneThe email to be used (Only OpenGmail and OpenOutlook).
ccStringnoneThe email to be used like CC (Only OpenGmail and OpenOutlook).
bccStringnoneThe email to be used like CCO (Only OpenGmail and OpenOutlook).
subjectStringnoneThe subject to be used in the mail (Only OpenGmail and OpenOutlook).
bodyStringnoneThe body to be used in the mail (Only OpenGmail and OpenOutlook).
linkToUseStringliveChoose mail link with these options: "live" or "office365" (Only OpenOutlook).
onCopyBooleanfalseUsed to recive true or false if it was possible or not make the copy (Only CopyToClipboard).
idButtonStringa textThe button id (All).
titleTextStringnullThe button title (All).
ariaLabelStringnullThe button aria-label (All).
classesStringnullThe class or classes to be applied to the button (All).
stylesstyle objectnullThe styles to be applied to the button (All).
childrenReactNodea textUse this to add some custom content inside the button (All).

Examples

CopyToClipboard

import React from "react";
import { CopyToClipboard } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <CopyToClipboard 
            tel="+123456789" 
            onCopy={(e) => console.log(e)} 
        />
    </div>
);

Basic button (If no styles and children are applied) it will look like this: basicCopyButton and you will see true or false in console.

OpenWhatsApp

import React from "react";
import { OpenWhatsApp } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <OpenWhatsApp 
            tel="+123456789" 
            msg="Some Message"
            styles={{ 
                backgroundColor: 'transparent', 
                border: 'none', 
                borderRadius: '12px', 
                margin: '0px', 
                padding: '0px' 
            }}
        >
            <img alt="Chat on WhatsApp" src="WhatsAppButtonGreenLarge.svg" />
        </OpenWhatsApp>
    </div>
);

Button with some styles and an image as children, looks like this: chatOnWhatsapp Download image here

OpenTelegram

import React from "react";
import { OpenTelegram } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <OpenTelegram 
            tUser="+12345678" or "username" 
            styles={{ 
                backgroundColor: 'transparent', 
                border: 'none', 
                borderRadius: '50%', 
                margin: '0px', 
                padding: '0px' 
            }}
        >
            <img alt="Chat on Telegram" src="Logo.svg" width="50px" height="50px"/>
        </OpenTelegram>
    </div>
);

Button with some styles and an image as children, looks like this: chatOnTelegram Download image here

OpenSkypeSoftware

import React from "react";
import { OpenSkypeSoftware } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <OpenSkypeSoftware 
            sUser="Skype name" 
            action="chat" 
            styles={{ backgroundColor: 'transparent', border: 'none' }}
        >
            <img alt="Skype Software" src="chatbutton_32px.png" />
        </OpenSkypeSoftware>
    </div>
);

Button with some styles and an image as children, looks like this: chatbutton_32px Download image here, please follow the brand-guidelines for the correct use of the name, icons and images.

OpenGmail

import React from "react";
import { OpenGmail } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <OpenGmail 
            to="email@domain.com" 
            cc="emailcc@domain.com" 
            bcc="emailbcc@domain.com" 
            subject="Some subject" 
            body="Some body"
            classes={"btn btn-primary"}
        >
            Use Gmail
        </OpenGmail>
    </div>
);

Button with Bootstrap class and a text as children, looks like this: bootstrapClassButton (you must have bootstrap installed in your project).

OpenOutlook

import React from "react";
import { OpenOutlook } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <OpenOutlook 
            to="email@domain.com" 
            cc="emailcc@domain.com" 
            bcc="emailbcc@domain.com" 
            subject="Some subject" 
            body="Some body" 
            classes="contact"
        >
            Use Outlook
        </OpenOutlook>
    </div>
);

Button if you add some css styles and a text as children, looks like this: cssButton

CallTo

import React from "react";
import { CallTo } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <CallTo tel="+123456789" titleText="Press to Call" />
    </div>
);

Button if you add titleText, the classic tooltip will appear, looks like this: buttonTitle

SmsTo

import React from "react";
import { SmsTo } from 'react-contact-buttons'

const YourComponent = () => (
    <div>
        <SmsTo 
            tel="+123456789" 
            msg="Some Message"
            idButton="SmsBut"
            ariaLabel="sms" 
        />
    </div>
);

The idea is to build something pressable so that the user can interact with the page and make the contact.

1.4.3

1 year ago

1.3.3

1 year ago

1.2.3

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago