Example of Social Icons using React Native Elements

Introduction

This is an example of Social Icon using React Native Elements. React Native Element provides lots of cool stuff to use while making a React Native Application and Social Icons are one of them. Developers from a web development background can imagine it is like fa-fa icons. You just need to import react-native-elements library and you are ready to use almost all the popular social icons in your app.

To make Social Icons using React Native Elements have a look at the following code snippet.

How to use SocialIcon (Circular)?

<SocialIcon
  //Social Icon using react-native-elements
  type="twitter"
  //Type of Social Icon
  onPress={() => {
    //Action to perform on press of Social Icon
    this._toggleBottomNavigationView();
    alert('twitter');
  }}
/>

How to use Social Icon (Button)?

<SocialIcon
  //Social Icon using react-native-elements
  button
  //To make a button type Social Icon
  title="Sign In facebook"
  //Title of Social Button
  type="facebook"
  //Type of Social Icon
  onPress={() => {
    //Action to perform on press of Social Icon
    alert('facebook');
  }}
/>

List of Social Icons Available

Here is the list of Social Icons which can be by made easily by changing the type prop in SocialIcon component.

angellistenvelopecodepenenvelopeetsyfacebook
foursquaregithub-altgithubgitlabinstagramlinkedin
mediumpinterestquorareddit-aliensoundcloudstack-overflow
steamstumbleupontumblrtwitchtwittergoogle-plus-official
vimeowordpressyoutube

To Make a React Native App

Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility. Open the terminal and go to the workspace and run

npm install -g react-native-cli

Run the following commands to create a new React Native project

react-native init ProjectName

If you want to start a new project with a specific React Native version, you can use the --version argument:

react-native init ProjectName --version X.XX.X
react-native init ProjectName --version react-native@next

This will make a project structure with an index file named App.js in your project directory.

Installation of Dependencies

To use ScialIcons we have to install react-native-elements and react-native-vector-icons dependencies.

For installation open the terminal and jump into your project using.

cd ProjectName

Run the following command.

npm install react-native-elements --save
npm install react-native-vector-icons --save

Please visit Example to Use React Native Vector Icons for further instructions to complete the installation of Vector Icons.

CocoaPods Installation

Now we need to install pods

cd ios && pod install && cd ..

Code

Now Open App.js in any code editor and replace the code with the following code

App.js

// Example of Social Icons using React Native Elements
// https://aboutreact.com/react-native-social-icon/

// Import React
import React from 'react';

// Import required component
import {SafeAreaView, StyleSheet, ScrollView, Text, View} from 'react-native';

// Import to show social icons
import {SocialIcon} from 'react-native-elements';

const App = () => {
  return (
    <SafeAreaView style={{flex: 1}}>
      <ScrollView>
        <View style={styles.container}>
          <Text style={styles.heading}>
            Example of Social Icons using React Native Elements
          </Text>
          <Text style={styles.textStyle}>www.aboutreact.com</Text>
          <View
            style={{
              flex: 1,
              flexDirection: 'column',
              justifyContent: 'space-between',
            }}>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  //Social Icon using react-native-elements
                  type="angellist"
                  //Type of Social Icon
                  onPress={() => {
                    //Action to perform onPress of the Icon
                    alert('angellist');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  angellist
                </Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="codepen"
                  onPress={() => {
                    alert('codepen');
                  }}
                />
                <Text style={{textAlign: 'center'}}>codepen</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="envelope"
                  onPress={() => {
                    alert('envelope');
                  }}
                />
                <Text style={{textAlign: 'center'}}>envelope</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="etsy"
                  onPress={() => {
                    alert('etsy');
                  }}
                />
                <Text style={{textAlign: 'center'}}>etsy</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="facebook"
                  onPress={() => {
                    alert('facebook');
                  }}
                />
                <Text style={{textAlign: 'center'}}>facebook</Text>
              </View>
            </View>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="foursquare"
                  onPress={() => {
                    alert('foursquare');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  foursquare
                </Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="github-alt"
                  onPress={() => {
                    alert('github');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  github-alt
                </Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="github"
                  onPress={() => {
                    alert('github');
                  }}
                />
                <Text style={{textAlign: 'center'}}>github</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="gitlab"
                  onPress={() => {
                    alert('gitlab');
                  }}
                />
                <Text style={{textAlign: 'center'}}>gitlab</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="instagram"
                  onPress={() => {
                    alert('instagram');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  instagram
                </Text>
              </View>
            </View>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="linkedin"
                  onPress={() => {
                    alert('linkedin');
                  }}
                />
                <Text style={{textAlign: 'center'}}>linkedin</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="medium"
                  onPress={() => {
                    alert('medium');
                  }}
                />
                <Text style={{textAlign: 'center'}}>medium</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="pinterest"
                  onPress={() => {
                    alert('pinterest');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  pinterest
                </Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="quora"
                  onPress={() => {
                    alert('quora');
                  }}
                />
                <Text style={{textAlign: 'center'}}>quora</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="reddit-alien"
                  onPress={() => {
                    alert('reddit');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  reddit-alien
                </Text>
              </View>
            </View>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="soundcloud"
                  onPress={() => {
                    alert('soundcloud');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  soundcloud
                </Text>
              </View>

              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="steam"
                  onPress={() => {
                    alert('steam');
                  }}
                />
                <Text style={{textAlign: 'center'}}>steam</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="youtube"
                  onPress={() => {
                    alert('youtube');
                  }}
                />
                <Text style={{textAlign: 'center'}}>youtube</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="tumblr"
                  onPress={() => {
                    alert('tumblr');
                  }}
                />
                <Text style={{textAlign: 'center'}}>tumblr</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="twitch"
                  onPress={() => {
                    alert('twitch');
                  }}
                />
                <Text style={{textAlign: 'center'}}>twitch</Text>
              </View>
            </View>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="twitter"
                  onPress={() => {
                    alert('twitter');
                  }}
                />
                <Text style={{textAlign: 'center'}}>twitter</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="vimeo"
                  onPress={() => {
                    alert('vimeo');
                  }}
                />
                <Text style={{textAlign: 'center'}}>vimeo</Text>
              </View>
              <View style={{flexDirection: 'column'}}>
                <SocialIcon
                  type="wordpress"
                  onPress={() => {
                    alert('wordpress');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  wordpress
                </Text>
              </View>
              <View
                style={{
                  flexDirection: 'column',
                  alignItems: 'center'
                }}>
                <SocialIcon
                  type="stumbleupon"
                  onPress={() => {
                    alert('stumbleupon');
                  }}
                />
                <Text style={{textAlign: 'center'}}>
                  stumbleupon
                </Text>
              </View>
            </View>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <View
                style={{
                  flex: 1,
                  flexDirection: 'row',
                  alignContent: 'center',
                  justifyContent: 'center',
                }}>
                <View
                  style={{
                    width: '100%',
                    alignItems: 'center',
                    flexDirection: 'column',
                  }}>
                  <SocialIcon
                    type="stack-overflow"
                    onPress={() => {
                      alert('stack');
                    }}
                  />
                  <Text style={{flex: 1, textAlign: 'center'}}>
                    stack-overflow
                  </Text>
                </View>
              </View>
              <View
                style={{
                  flex: 1,
                  flexDirection: 'row',
                  alignContent: 'center',
                  justifyContent: 'center',
                }}>
                <View
                  style={{
                    width: '100%',
                    alignItems: 'center',
                    flexDirection: 'column',
                  }}>
                  <SocialIcon
                    type="google-plus-official"
                    onPress={() => {
                      alert('google');
                    }}
                  />
                  <Text style={{textAlign: 'center'}}>
                    google-plus-official
                  </Text>
                </View>
              </View>
            </View>
          </View>

          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In angellist"
              button
              type="angellist"
              onPress={() => {
                alert('angellist');
              }}
            />
            <Text style={{textAlign: 'center'}}>angellist</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In codepen"
              button
              type="codepen"
              onPress={() => {
                alert('codepen');
              }}
            />
            <Text style={{textAlign: 'center'}}>codepen</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In envelope"
              button
              type="envelope"
              onPress={() => {
                alert('envelope');
              }}
            />
            <Text style={{textAlign: 'center'}}>envelope</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In etsy"
              button
              type="etsy"
              onPress={() => {
                alert('etsy');
              }}
            />
            <Text style={{textAlign: 'center'}}>etsy</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              //Social Icon using react-native-elements
              button
              //To make a button type Social Icon
              title="Sign In facebook"
              //Title of Social Button
              type="facebook"
              //Type of Social Icon
              onPress={() => {
                //Action to perform on press of Social Icon
                alert('facebook');
              }}
            />
            <Text style={{textAlign: 'center'}}>facebook</Text>
          </View>

          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In foursquare"
              button
              type="foursquare"
              onPress={() => {
                alert('foursquare');
              }}
            />
            <Text style={{textAlign: 'center'}}>foursquare</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In Github Alt"
              alt
              button
              type="github-alt"
              onPress={() => {
                alert('github-alt');
              }}
            />
            <Text style={{textAlign: 'center'}}>github-alt</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In github"
              button
              type="github"
              onPress={() => {
                alert('github');
              }}
            />
            <Text style={{textAlign: 'center'}}>github</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In gitlab"
              button
              type="gitlab"
              onPress={() => {
                alert('gitlab');
              }}
            />
            <Text style={{textAlign: 'center'}}>gitlab</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In instagram"
              button
              type="instagram"
              onPress={() => {
                alert('instagram');
              }}
            />
            <Text style={{textAlign: 'center'}}>instagram</Text>
          </View>

          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In linkedin"
              button
              type="linkedin"
              onPress={() => {
                alert('linkedin');
              }}
            />
            <Text style={{textAlign: 'center'}}>linkedin</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In medium"
              button
              type="medium"
              onPress={() => {
                alert('medium');
              }}
            />
            <Text style={{textAlign: 'center'}}>medium</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In pinterest"
              button
              type="pinterest"
              onPress={() => {
                alert('pinterest');
              }}
            />
            <Text style={{textAlign: 'center'}}>pinterest</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In quora"
              button
              type="quora"
              onPress={() => {
                alert('quora');
              }}
            />
            <Text style={{textAlign: 'center'}}>quora</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In reddit-alien"
              button
              type="reddit-alien"
              onPress={() => {
                alert('reddit');
              }}
            />
            <Text style={{textAlign: 'center'}}>reddit-alien</Text>
          </View>

          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In soundcloud"
              button
              type="soundcloud"
              onPress={() => {
                alert('soundcloud');
              }}
            />
            <Text style={{textAlign: 'center'}}>soundcloud</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In Stack Overflow"
              button
              type="stack-overflow"
              onPress={() => {
                alert('stack-overflow');
              }}
            />
            <Text style={{textAlign: 'center'}}>
              stack-overflow
            </Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In steam"
              button
              type="steam"
              onPress={() => {
                alert('steam');
              }}
            />
            <Text style={{textAlign: 'center'}}>steam</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In youtube"
              button
              type="youtube"
              onPress={() => {
                alert('youtube');
              }}
            />
            <Text style={{textAlign: 'center'}}>youtube</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In tumblr"
              button
              type="tumblr"
              onPress={() => {
                alert('tumblr');
              }}
            />
            <Text style={{textAlign: 'center'}}>tumblr</Text>
          </View>

          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In twitch"
              button
              type="twitch"
              onPress={() => {
                alert('twitch');
              }}
            />
            <Text style={{textAlign: 'center'}}>twitch</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In twitter"
              button
              type="twitter"
              onPress={() => {
                alert('twitter');
              }}
            />
            <Text style={{textAlign: 'center'}}>twitter</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In Google Plus"
              button
              type="google-plus-official"
              onPress={() => {
                alert('google');
              }}
            />
            <Text style={{textAlign: 'center'}}>
              google-plus-official
            </Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In vimeo"
              button
              type="vimeo"
              onPress={() => {
                alert('vimeo');
              }}
            />
            <Text style={{textAlign: 'center'}}>vimeo</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In wordpress"
              button
              type="wordpress"
              onPress={() => {
                alert('wordpress');
              }}
            />
            <Text style={{textAlign: 'center'}}>wordpress</Text>
          </View>
          <View style={{width: '100%', flexDirection: 'column'}}>
            <SocialIcon
              title="Sign In stumbleupon"
              button
              type="stumbleupon"
              onPress={() => {
                alert('stumbleupon');
              }}
            />
            <Text style={{textAlign: 'center'}}>stumbleupon</Text>
          </View>
        </View>
      </ScrollView>
    </SafeAreaView>
  );
};
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    padding: 16,
  },
  heading: {
    fontSize: 20,
    textAlign: 'center',
  },
  textStyle: {
    fontSize: 16,
    textAlign: 'center',
    color: 'grey',
    marginVertical: 16,
  },
});

export default App;

To Run the React Native App

Open the terminal again and jump into your project using.

cd ProjectName

To run the project on an Android Virtual Device or on real debugging device

react-native run-android

or on the iOS Simulator by running (macOS only)

react-native run-ios

Download Source Code

Output Screenshots

         

Output in Online Emulator

That was the example of Social Icons using React Native Elements. If you have any doubts or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!

Hope you liked it. 🙂

2 thoughts on “Example of Social Icons using React Native Elements”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.