React Native UI Toolkit (renamed to @rneui/themed)

3.4.3 · renamed · verified Tue Apr 21

React Native Elements is a cross-platform UI toolkit providing a set of pre-built, customizable components for React Native applications. It aims to simplify the development of mobile interfaces by offering a consistent design language and a wide array of commonly used UI elements like buttons, cards, forms, and more. While this `react-native-elements` package is still available, it has been formally renamed to `@rneui/themed` starting with its v4 release. The current stable version for `react-native-elements` is 3.4.3, but the active development and new features are primarily happening under the `@rneui/themed` package, which is currently at v5.0.0. Developers are strongly encouraged to migrate to `@rneui/themed` for ongoing support, new features, and bug fixes, as this original package is considered deprecated and effectively in maintenance mode. Its key differentiators include comprehensive theming capabilities and a focus on ease of use with minimal boilerplate.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `ThemeProvider` with a custom theme and use `Button`, `Avatar`, and `Card` components from `@rneui/themed` (the successor to react-native-elements). It showcases basic component usage and theming.

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Button, createTheme, ThemeProvider, Avatar, Card } from '@rneui/themed';

const theme = createTheme({
  components: {
    Button: {
      buttonStyle: {
        backgroundColor: 'blue',
        borderRadius: 10,
      },
      titleStyle: {
        color: 'white',
      },
    },
    Card: {
      containerStyle: {
        borderRadius: 15,
        padding: 20,
      }
    }
  },
});

function MyComponent() {
  return (
    <ThemeProvider theme={theme}>
      <View style={styles.container}>
        <Text style={styles.title}>Welcome to @rneui/themed!</Text>
        <Button
          title="Click Me!"
          onPress={() => console.log('Button pressed')}
          containerStyle={styles.buttonContainer}
        />
        <Avatar
          size="large"
          rounded
          source={{ uri: 'https://randomuser.me/api/portraits/women/4.jpg' }}
          title="LV"
          containerStyle={{ backgroundColor: 'grey', marginTop: 20 }}
        />
        <Card containerStyle={styles.cardContainer}>
          <Card.Title>Hello Card</Card.Title>
          <Card.Divider />
          <Text>This is a custom themed card!</Text>
        </Card>
      </View>
    </ThemeProvider>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#f5f5f5',
    padding: 20,
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 30,
    color: '#333',
  },
  buttonContainer: {
    width: '80%',
    marginVertical: 10,
  },
  cardContainer: {
    width: '90%',
    marginTop: 20
  }
});

export default MyComponent;

view raw JSON →