Giter VIP home page Giter VIP logo

react-native-elements's Introduction

React Native Elements

React Native UI Toolkit

React Native UI Toolkit

Get Started

Step 1

Install rnpm if not already installed on your machine

npm install rnpm -g

####Step 2

Install React Native Elements

npm i react-native-elements --save

Step 3

Link project

rnpm link

Step 4

Start using components

import {
  RNEButton,
  RNECard,
  RNEFormInput,
  RNEFormLabel,
  RNEList,
  RNEListItem,
  RNEPricingCard,
  RNESocialIcon,
  RNEText,
  RNEDivider
} from 'react-native-elements'

<RNEButton
  raised
  icon={{name: 'cached'}}
  title='RAISED WITH ICON' />

Included

Roadmap

  • Add light options for social icons
  • Add divider with inset
  • Add radio buttons
  • Add icons to TextInputs
  • Profile Component
  • Custom Picker
  • Search Bar
  • Side Menu Improvements
  • Cross Platform Tab Bar
  • Something you's like to see? Submit an issue or a pull request

Examples

Check out the pre built and configured React Native Hackathon Starter Project which uses all of these elements.

API

Buttons

Buttons

import { RNEButton } from 'react-native-elements'

<RNEButton
  title='BUTTON' />

<RNEButton
  raised
  icon={{name: 'cached'}}
  title='RAISED WITH ICON' />

<RNEButton
  small
  iconRight
  icon={{name: 'code'}}
  title='SMALL WITH RIGHT ICON' />

RNEButton props

prop default type description
buttonStyle none object (style) add additional styling for button component (optional)
title none string button title (required)
small false boolean makes button small
iconRight false boolean moves icon to right of title
onPress none function onPress method (required)
icon none object {name(string), color(string), size(number)} Material Icon Name (optional)
backgroundColor #397af8 string (color) background color of button (optional)
color white string(color) font color (optional)
textStyle none object (style) text styling (optional)
fontSize 18 number font size (optional)
underlayColor transparent string(color) underlay color for button press (optional)
raised false boolean flag to add raised button styling (optional)

Social Icons & Buttons

Social Icons

import { RNESocialIcon } from 'react-native-elements'

// Icon
<RNESocialIcon
  type='twitter'
/>

// Button
<RNESocialIcon
  title='Sign In With Facebook'
  button
  type='facebook'
/>

RNESocialIcon props

prop default type description
component TouchableHighlight React Native Component type of button (optional)
type none social media type (facebook, twitter, google-plus-official, pinterest, linkedin, youtube, vimeo, tumblr, instagram, quora, foursquare, wordpress, stumbleupon) social media type (required)
button false boolean creates button (optional)
onPress none funciton onPress method (optional)
iconStyle none object (style) extra styling for icon component (React Native Vector Icons) (optional)
style none object (style) button styling (optional)
iconColor white string icon color (optional)
title none string title if made into a button (optional)

Lists

Lists

Using Map Function. Implemented with icons.

import { RNEList, RNEListItem } from 'react-native-elements'

const list = [
  {
    title: 'Appointments',
    icon: 'av-timer'
  },
  {
    title: 'Trips',
    icon: 'flight-takeoff'
  }
]

<RNEList>
  {
    list.map((item, i) => (
      <RNEListItem
        key={i}
        title={item.title}
        icon={{name: item.icon}}
      />
    ))
  }
</RNEList>

Using RN ListView. Implemented with avatars.

import { RNEList, RNEListItem } from 'react-native-elements'

const list = [
  {
    name: 'Amy Farha',
    avatar_url: 'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg',
    subtitle: 'Vice President'
  },
  {
    name: 'Chris Jackson',
    avatar_url: 'https://s3.amazonaws.com/uifaces/faces/twitter/adhamdannaway/128.jpg',
    subtitle: 'Vice Chairman'
  }
]

renderRow (rowData, sectionID) {
  return (
    <RNEListItem
      roundAvatar
      key={sectionID}
      title={rowData.name}
      subtitle={rowData.subtitle}
      avatar={rowData.avatar_url}
    />
  )
}

render () {  
  return (
    <RNEList>
      <ListView
        renderRow={this.renderRow}
        dataSource={this.state.dataSource}
      />
    </RNEList>
  )
}

RNEList Props

prop default type description
containerStyle none object (style) style the list container

RNEListItem props

prop default type description
avatar none string left avatar (optional)
avatarStyle none object (style) avatar styling (optional)
chevronColor #bdc6cf string set chevron color
component View or TouchableHighlight if onPress method is added as prop React Native element replace element with custom element (optional)
containerStyle none object (style) additional main container styling (optional)
hideChevron false boolean set if you do not want a chevron (optional)
icon none object {name, color, style} icon configuration for left icon (optional)
onPress none function onPress method for link (optional)
rightIcon chevron string right icon (optional) (material icon name)
roundAvatar false boolan make left avatar round
subtitle none string subtitle text (optional)
subtitleStyle none object (style) additional subtitle styling (optional )
title none string main title for list item (required)
titleStyle none object (style) additional title styling (optional)
wrapperStyle none object (style) additional wrapper styling (optional)
underlayColor white string define underlay color for TouchableHighlight (optional)

SideMenu

Side Menu

import { RNESideMenu, RNEListItem } from 'react-native-elements'

constructor () {
  super()
  this.state = { toggled: false }
}

toggleSideMenu () {
  this.setState({
    toggled: true
  })
}

render () {
  // RNESideMenu takes a React Native element as a prop for the actual Side Menu
  const MenuComponent = (
    <View style={{flex: 1, backgroundColor: '#ededed', paddingTop: 50}}>
      <RNEList containerStyle={{marginBottom: 20}}>
      {
        list.map((item, i) => (
          <RNEListItem
            roundAvatar
            onPress={() => console.log('something')}
            avatar={item.avatar_url}
            key={i}
            title={item.name}
            subtitle={item.subtitle} />
        ))
      }
      </RNEList>
    </View>
  )
  return (
    <RNESideMenu
      MenuComponent={MenuComponent}
      toggled={this.state.toggled}>
      <App />
    </RNESideMenu>
  )
}

RNESideMenu props

prop default type description
toggled false boolean toggles side menu when true (required)
easing Easing.inout Easing method specifies different easing method (optional)
duration 250 animation length specifies length of animation (optional)
menuWidth window width - 80 number the width and offset of the menu (optional)
MenuComponent none React Native Component the actual side menu component you would like to use (required)
children none React Native Component wrap RNSideMenu around the component you would like to animate (required)

Forms

Forms

import { RNEFormLabel, RNEFormInput } from 'react-native-elements'

<RNEFormLabel containerStyle={styles.labelContainerStyle}>Name</RNEFormLabel>
<RNEFormInput onChangeText={someFunction}/>

RNEFormInput props

prop default type description
containerStyle none object (style) TextInput container styling (optional)
inputStyle none object (style) TextInput styling (optional)

RNEFormLabel props

prop default type description
containerStyle none object (style) additional label container style (optional)
labelStyle none object (style) additional label styling (optional)

Card

Card Component

import { RNECard } from 'react-native-elements'

<RNECard
  title='CARD WITH DIVIDER'>
  {
    users.map((u, i) => {}
  }
</RNECard>

RNECard props

prop default type description
flexDirection column string flex direction (row or column) (optional)
containerStyle none object (style) outer container style (optional)
wrapperStyle none object (style) inner container style (optional)
title none string optional card title (optional)
titleStyle none object (style) additional title styling (if title provided) (optional)
dividerStyle none object (style) additional divider styling (if title provided) (optional)

Pricing Component

Pricing Component

import { RNEPricingCard } from 'react-native-elements'

<RNEPricingCard
  color={colors.primary}
  title='Free'
  price='$0'
  info={['1 User', 'Basic Support', 'All Core Features']}
  button={{ title: 'GET STARTED', icon: 'flight-takeoff' }}
/>

RNEPricingCard props

prop default type description
title none string title (required)
price none string price (required)
color none string color scheme for button & title (required)
info none array of strings pricing information (optional)
button none object {title, icon, buttonStyle} button information (required)
containerStyle inherited styling object (style) outer component styling (optional)
wrapperStyle inherited styling object (style) inner wrapper component styling (optional)

react-native-elements's People

Contributors

dabit3 avatar

Watchers

James Cloos avatar Carlos Cuatin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.