Skip to main content
Version: 4.0.0-rc.8

Installation

Stable

Stable version of React Native Elements available on npm

npm install @rneui/themed @rneui/base

Bleeding Edge

npm install @rneui/base@edge @rneui/themed@edge

If you are facing issue while installing from edge dist-tag, you can install directly from Github

# @rneui/base
npm install react-native-elements/react-native-elements#base

# @rneui/themed
npm install react-native-elements/react-native-elements#themed

Peer dependencies

Install react-native-vector-icons

Expo or create-react-native-app projects include react-native-vector-icons out of the box, hence this step can be skipped.

If your project is a standard React Native project created using react-native init (it should have an ios/android directory), then you need to install react-native-vector-icons.

Or if you encounter the following error.

note

If you see the UNMET PEER DEPENDENCY warning for react-native-vector-icons like below, you can ignore it as react-native-vector-icons is already installed by expo or crna.

React Native Vector Icons Unmet Peer Dependency

Otherwise run the following command:

tip

Manual linking of react-native-vector-icons is not necessary if you're using react-native@0.60.0 or above since it is done automatically. This will throw an error though it won't prevent the application from running. To fix this you'll simply have to run react-native unlink react-native-vector-icons and the process will run as expected.

npm install react-native-vector-icons

Link the dependency

npx react-native link react-native-vector-icons

If you have any issues installing react-native-vector-icons, check out their installation guide here or debug it using this issue.

Install react-native-safe-area-context

If you have already installed react-native-safe-area-context as a dependency for your project you can skip this step. Otherwise run the following command:

npm install react-native-safe-area-context
Useful information.

Manual linking of react-native-safe-area-context is not necessary if you're using react-native@0.60.0 or above since it is done automatically. This will throw an error though it won't prevent the application from running. To fix this you'll simply have to run react-native unlink react-native-safe-area-context and the process will run as expected.

npx react-native link react-native-safe-area-context

It is required to add the SafeAreaProvider to the outside of the app. The suggested way to do this is the following:

import { SafeAreaProvider } from 'react-native-safe-area-context';

function App() {
return <SafeAreaProvider>...</SafeAreaProvider>;
}

Using Expo

New Expo project

Create a new project with Expo CLI and React Native Elements template

npx create-expo-app --template @rneui/template

Existing Expo project

Just install the package and its peer dependencies

Using on Web

React Native Elements just like on mobile can be used in your web projects. This is possible using react-native-web. We'll highlight how to set this up using create-react-app.

Why do I have to set this up?

On the web, you can usually use UI libraries directly from npm without any additional setup. However in react-native, it's a bit different.

The major difference is that React Native can support JSX and advanced javascript out the box. This means that we don't need to transpile our code before we ship it to npm. We ship JSX and advanced javascript directly to npm in React Native Elements, so we need to account for this in our web projects.

Create React App

Create React App is a very popular framework for building react applications. Unfortunately it doesn't allow much customization of the build setup. To accomplish this we'll be making use of react-app-rewired and customize-cra.

After creating a new create-react-app project, run the following commands.

yarn add  @rneui/base @rneui/themed react-native-web react-native-vector-icons
yarn add --dev @babel/plugin-proposal-class-properties customize-cra react-app-rewired

Secondly, create a config-overrides.js file in the root of your project.

const path = require('path');
const { override, addBabelPlugins, babelInclude } = require('customize-cra');

module.exports = override(
...addBabelPlugins('@babel/plugin-proposal-class-properties'),
babelInclude([
path.resolve(__dirname, 'node_modules/@rneui/base'),
path.resolve(__dirname, 'node_modules/@rneui/themed'),
path.resolve(__dirname, 'node_modules/react-native-vector-icons'),
path.resolve(__dirname, 'node_modules/react-native-ratings'),
path.resolve(__dirname, 'src'),
])
);

Also you should keep in mind that not all of React Native components are implemented for web-platform out-of-box. For example, Modal component is not yet implemented in react-native-web. Therefore, to use some of our components you may need to install additional third-party libraries that implement the missing functionality. For Overlay and Tooltip components Modal implementation is required.

Lastly, change your scripts in package.json to use react-app-rewired:

"scripts": {
- "start": "react-scripts start",
+ "start": "react-app-rewired start",
- "build": "react-scripts build",
+ "build": "react-app-rewired build",
- "test": "react-scripts test",
+ "test": "react-app-rewired test"
}

At this point your app can start. However trying to use any components that use icons, will not show them. In your App.js, load these fonts as you would on the web with a style tag.

<style type="text/css">{`
@font-face {
font-family: 'MaterialIcons';
src: url(${require('react-native-vector-icons/Fonts/MaterialIcons.ttf')}) format('truetype');
}

@font-face {
font-family: 'FontAwesome';
src: url(${require('react-native-vector-icons/Fonts/FontAwesome.ttf')}) format('truetype');
}
`}</style>

The full setup of the guide can be found at https://github.com/react-native-elements/create-react-app-example.