1.0.1 • Published 7 years ago

@cross2d/react-web-elements v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

React Native Elements

Cross Platform React Native UI Toolkit

React Native UI Toolkit

Get Started

If you are using Exponent, you can run npm i react-native-elements --save and skip to step 3.

Step 1

Install react-native-vector-icons (if you do not already have it)

npm i react-native-vector-icons --save && react-native link react-native-vector-icons

If you have any issues with icons not working or installation of React Native Vector Icons, check out their installation guide here

Step 2

Install React Native Elements

npm i react-native-elements --save

or

yarn add react-native-elements

Step 3

Start using components

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

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

Included

Roadmap

Examples

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

Notes

Fonts

React Native Elements uses the System font as the default font family for iOS and Roboto as the default font family for Android.

In the example screenshots, we are using Lato which can be downloaded here.

We are working on a way to make a custom font family configurable through the command line.

Here is a list of fonts available out of the box for each platform, or you can install and use a custom font of your own.

To override the fontFamily in any element, simply provide a fontFamily prop:

<Button
  raised
  icon={{name: 'cached'}}
  title='RAISED WITH ICON'
  fontFamily='Comic Sans MS' />

API

Buttons

Buttons take a title and an optional material icon name, as well as the props below.

You can override Material icons with one of the following: material-community, simple-line-icon, zocial, font-awesome, octicon, ionicon, foundation, evilicon, or entypo by providing an icon.type as a prop.

Buttons

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

<Button
  title='BUTTON' />

<Button
  raised
  icon={{name: 'cached'}}
  title='BUTTON WITH ICON' />

<Button
  large
  iconRight
  icon={{name: 'code'}}
  title='LARGE WITH RIGHT ICON' />

<Button
  large
  icon={{name: 'envira', type: 'font-awesome'}}
  title='LARGE WITH RIGHT ICON' />

<Button
  large
  icon={{name: 'squirrel', type: 'octicon', buttonStyle: styles.someButtonStyle }}
  title='OCTICON' />

Button props

Also recevies all TouchableWithoutFeedback props

propdefaulttypedescription
ComponentTouchableHighlight (iOS), TouchableNativeFeedback (android)React Native ComponentSpecify other component such as TouchableOpacity or other (optional)
buttonStylenoneobject (style)add additional styling for button component (optional)
titlenonestringbutton title (required)
largefalsebooleanmakes button large
fontFamilySystem font (iOS), Roboto (android)stringspecify different font family
fontWeightnonestringspecify font weight for title (optional)
iconRightfalsebooleanmoves icon to right of title
onPressnonefunctiononPress method (required)
onLongPressnonefunctiononLongPress method (optional)
icon{color: 'white'}object {name: string, color: string, size: number, type: string (default is material, or choose one of material-community, simple-line-icon, zocial, font-awesome, octicon, ionicon, foundation, evilicon, or entypo), style: object(style)}icon configuration (optional)
backgroundColor#397af8string (color)background color of button (optional)
borderRadiusnonenumberadds border radius to card (optional)
colorwhitestring(color)font color (optional)
textStylenoneobject (style)text styling (optional)
fontSize18numberfont size (optional)
underlayColortransparentstring(color)underlay color for button press (optional)
raisedfalsebooleanflag to add raised button styling (optional)
disabledfalsebooleanprop to indicate button is disabled (optional)
disabledStylenoneobject (style)disabled button styling (optional)

Social Icons & Buttons

Social Icons

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

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

<SocialIcon
  raised={false}
  type='gitlab'
/>

<SocialIcon
  light
  type='medium'
/>

<SocialIcon
  light
  raised={false}
  type='medium'
/>


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

<SocialIcon
  title='Some Twitter Message'
  button
  type='twitter'
/>

<SocialIcon
  button
  type='medium'
/>


<SocialIcon
  button
  light
  type='instagram'
/>

SocialIcon props

propdefaulttypedescription
titlenonestringtitle if made into a button (optional)
typenonesocial media type (facebook, twitter, google-plus-official, pinterest, linkedin, youtube, vimeo, tumblr, instagram, quora, foursquare, wordpress, stumbleupon, github, github-alt, twitch, medium, soundcloud, gitlab, angellist, codepen)social media type (required)
raisedtruebooleanraised adds a drop shadow, set to false to remove
buttonfalsebooleancreates button (optional)
onPressnonefunctiononPress method (optional)
onLongPressnonefunctiononLongPress method (optional)
lightfalsebooleanreverses icon color scheme, setting background to white and icon to primary color
iconStylenoneobject (style)extra styling for icon component (optional)
stylenoneobject (style)button styling (optional)
iconColorwhitestringicon color (optional)
iconSize24numbericon size (optional)
componentTouchableHighlightReact Native Componenttype of button (optional)
fontFamilySystem font bold (iOS), Roboto-Black (android)stringspecify different font family (optional)
fontWeightbold (ios), black(android)stringspecify font weight of title if set as a button with a title
fontStylenoneobject (style)specify text styling (optional)
disabledfalsebooleandisable button (optional)
loadingfalsebooleanshows loading indicator (optional)

Icons & Icon Buttons

Icons

Icons take the name of a material icon as a prop.

You can override Material icons with one of the following: material-community, font-awesome, octicon, ionicon, foundation, evilicon, simple-line-icon, zocial, or entypo by providing a type prop.

Hint: use reverse to make your icon look like a button

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

<Icon
  name='rowing' />

<Icon
  name='g-translate'
  color='#00aced' />

<Icon
  name='sc-telegram'
  type='evilicon'
  color='#517fa4'
/>

<Icon
  reverse
  name='ios-american-football'
  type='ionicon'
  color='#517fa4'
/>

<Icon
  raised
  name='heartbeat'
  type='font-awesome'
  color='#f50'
  onPress={() => console.log('hello')} />

Icon props

propdefaulttypedescription
namenonestringname of icon (required)
typematerialstringtype (defaults to material, options are material-community, zocial, font-awesome, octicon, ionicon, foundation, evilicon, simple-line-icon, or entypo)
size26numbersize of icon (optional)
colorblackstringcolor of icon (optional)
iconStyleinherited styleobject (style)additional styling to icon (optional)
componentView if no onPress method is defined, TouchableHighlight if onPress method is definedReact Native componentupdate React Native Component (optional)
onPressnonefunctiononPress method for button (optional)
onLongPressnonefunctiononLongPress method for button (optional)
underlayColoricon colorstringunderlayColor for press event
reversefalsebooleanreverses color scheme (optional)
raisedfalsebooleanadds box shadow to button (optional)
containerStyleinherited stylingobject (style)add styling to container holding icon (optional)
reverseColorwhitestringspecify reverse icon color (optional)

Lists

Lists

Using Map Function. Implemented with avatar.

import { List, ListItem } 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'
  },
  ... // more items
]

<List containerStyle={{marginBottom: 20}}>
  {
    list.map((l, i) => (
      <ListItem
        roundAvatar
        avatar={{uri:l.avatar_url}}
        key={i}
        title={l.name}
      />
    ))
  }
</List>

Using Map Function. Implemented with link and icon.

import { List, ListItem } from 'react-native-elements'

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

<List>
  {
    list.map((item, i) => (
      <ListItem
        key={i}
        title={item.title}
        leftIcon={{name: item.icon}}
      />
    ))
  }
</List>

Using RN ListView. Implemented with link and avatar.

import { List, ListItem } 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'
  },
  ... // more items
]

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

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

ListItem implemented with custom View for Subtitle

import { List, ListItem } from 'react-native-elements'

render () {
  return (
    <List>
      <ListItem
        roundAvatar
        title='Limited supply! Its like digital gold!'
        subtitle={
          <View style={styles.subtitleView}>
            <Image source={require('../images/rating.png')} style={styles.ratingImage}/>
            <Text style={styles.ratingText}>5 months ago</Text>
          </View>
        }
        avatar={require('../images/avatar1.jpg')}
      />
    </List>
  )
}

styles = StyleSheet.create({
  subtitleView: {
    flexDirection: 'row',
    paddingLeft: 10,
    paddingTop: 5
  },
  ratingImage: {
    height: 19.21,
    width: 100
  },
  ratingText: {
    paddingLeft: 10,
    color: 'grey'
  }
})

List Props

propdefaulttypedescription
containerStylemarginTop: 20, borderTopWidth: 1, borderBottomWidth: 1, borderBottomColor: #cbd2d9object (style)style the list container

ListItem props

propdefaulttypedescription
avatarnoneobjectleft avatar (optional). Refer to React Native Image Source
avatarStylenoneobject (style)avatar styling (optional)
chevronColor#bdc6cfstringset chevron color
componentView or TouchableHighlight if onPress method is added as propReact Native elementreplace element with custom element (optional)
containerStylenoneobject (style)additional main container styling (optional)
hideChevronfalsebooleanset if you do not want a chevron (optional)
leftIconnoneobject {name, color, style, type} (type defaults to material icons)icon configuration for left icon (optional)
rightIcon{name: 'chevron-right'}object {name, color, style, type} (type defaults to material icons)icon configuration for right icon (optional). Shows up unless hideChevron or rightTitle is set
onPressnonefunctiononPress method for link (optional)
onLongPressnonefunctiononLongPress method for link (optional)
roundAvatarfalsebooleanmake left avatar round
subtitlenonestring or objectsubtitle text or custom view (optional)
subtitleContainerStylenonestyle (object)provide styling for subtitle container
subtitleStylenoneobject (style)additional subtitle styling (optional )
titlenonestring or objectmain title for list item, can be text or custom view (required)
titleStylenoneobject (style)additional title styling (optional)
titleContainerStylenonestyle (object)provide styling for title container
wrapperStylenoneobject (style)additional wrapper styling (optional)
underlayColorwhitestringdefine underlay color for TouchableHighlight (optional)
fontFamilyHelevticaNeue (iOS), Roboto (android)stringspecify different font family
rightTitlenonestringprovide a rightTitle to have a title show up on the right side of the button, will override any icon on the right
rightTitleContainerStyleflex: 1, alignItems: 'flex-end', justifyContent: 'center'object (style)style the outer container of the rightTitle text
rightTitleStylemarginRight: 5, color: '#bdc6cf'object (style)style the text of the rightTitle text
labelnonereact native componentadd a label with your own styling by providing a label={} prop to ListItem

Badges

Badges

You can now easily add a badge to your List Item

propdefaulttypedescription
badgenoneobject, accepts the following properties: value (string), badgeContainerStyle (object), badgeTextStyle (object). You can override the default badge by providing your own component with it's own styling by providing badge={{ element: }}add a badge to the ListItem by using this prop

Example badge usage

<ListItem
  ...
  badge={{ value: 3, badgeTextStyle: { color: 'orange' }, badgeContainerStyle: { marginTop: -20 } }}
/>

<ListItem
  ...
  badge={{ element: <MyCustomElement> }}
/>

SideMenu

Side Menu

This component implements react-native-side-menu which is part of the react-native-community.

import { SideMenu, List, ListItem } from 'react-native-elements'

constructor () {
  super()
  this.state = {
    isOpen: false
  }
  this.toggleSideMenu = this.toggleSideMenu.bind(this)
}

toggleSideMenu () {
  this.setState({
    isOpen: !this.state.isOpen
  })
}

render () {
  const MenuComponent = (
    <View style={{flex: 1, backgroundColor: '#ededed', paddingTop: 50}}>
      <List containerStyle={{marginBottom: 20}}>
      {
        list.map((l, i) => (
          <ListItem
            roundAvatar
            onPress={() => console.log('Pressed')}
            avatar={l.avatar_url}
            key={i}
            title={l.name}
            subtitle={l.subtitle}
          />
        ))
      }
      </List>
    </View>
  )

  return (
    <SideMenu
      isOpen={this.state.isOpen}
      menu={MenuComponent}>
      <App toggleSideMenu={this.toggleSideMenu.bind(this)} />
    </SideMenu>
  )
}

SideMenu props

propdefaulttypedescription
menuinheritedReact.ComponentMenu component
isOpenfalseBooleanProps driven control over menu open state
openMenuOffset2/3 of device screen widthNumberContent view left margin if menu is opened
hiddenMenuOffsetnoneNumberContent view left margin if menu is hidden
edgeHitWidthnoneNumberEdge distance on content view to open side menu, defaults to 60
toleranceXnoneNumberX axis tolerance
toleranceYnoneNumberY axis tolerance
disableGesturesfalseBoolDisable whether the menu can be opened with gestures or not
onStartShould SetResponderCapturenoneFunctionFunction that accepts event as an argument and specify if side-menu should react on the touch or not. Check https://facebook.github.io/react-native/docs/gesture-responder-system.html for more details
onChangenoneFunctionCallback on menu open/close. Is passed isOpen as an argument
onMovenoneFunctionCallback on menu move. Is passed left as an argument
menuPositionleftStringeither 'left' or 'right'
animationFunctionnone(Function -> Object)Function that accept 2 arguments (prop, value) and return an object: - prop you should use at the place you specify parameter to animate - value you should use to specify the final value of prop
animationStylenone(Function -> Object)Function that accept 1 argument (value) and return an object: - value you should use at the place you need current value of animated parameter (left offset of content view)
bounceBackOnOverdrawtruebooleanwhen true, content view will bounce back to openMenuOffset when dragged further

For issues or feature requests related to SideMenu component please click here

Search Bar

Search Bar

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

<SearchBar
  onChangeText={someMethod}
  placeholder='Type Here...' />

<SearchBar
  noIcon
  onChangeText={someMethod}
  placeholder='Type Here...' />

<SearchBar
  round
  onChangeText={someMethod}
  placeholder='Type Here...' />

<SearchBar
  lightTheme
  onChangeText={someMethod}
  placeholder='Type Here...' />

SearchBar props

This component inherits all native TextInput props that come with a standard React Native TextInput element, along with the following:
propdefaulttypedescription
containerStyleinherited stylingobject (style)style the container of the TextInput
inputStyleinherited stylingobject (style)style the TextInput
icon{ color: '#86939e', name: 'search' }object {name (string), color (string), style (object)}specify color, styling, or another Material Icon Name
noIconfalsebooleanremove icon from textinput
lightThemefalsebooleanchange theme to light theme
roundfalsebooleanchange TextInput styling to rounded corners
containerRefnonerefref for TextInput conainer
textInputRefnonerefref for TextInput
focusnonefunctioncall focus on the textinput(optional), eg this.refs.someInputRef.focus()
underlineColorAndroidtransparentstring (color)specify other than the default transparent underline color
loadingIcon{ color: '#86939e' }object {color (string), style (object)}specify color, styling of the loading ActivityIndicator effect
showLoadingIconfalsebooleanshow the loading ActivityIndicator effect
placeholder''stringset the placeholder text
placeholderTextColor'#86939e'stringset the color of the placeholder text
onChangeTextnonefunctionmethod to fire when text is changed

Tab Bar Component

Tab Bar Component

This component implements the react-native-tab-navigator from Exponent. Check out Exponent if you haven't already!

import { Tabs, Tab, Icon } from 'react-native-elements'

constructor() {
  super()
  this.state = {
    selectedTab: 'profile',
  }
}

changeTab (selectedTab) {
  this.setState({selectedTab})
}

const { selectedTab } = this.state

<Tabs>
  <Tab
    titleStyle={{fontWeight: 'bold', fontSize: 10}}
    selectedTitleStyle={{marginTop: -1, marginBottom: 6}}
    selected={selectedTab === 'feed'}
    title={selectedTab === 'feed' ? 'FEED' : null}
    renderIcon={() => <Icon containerStyle={{justifyContent: 'center', alignItems: 'center', marginTop: 12}} color={'#5e6977'} name='whatshot' size={33} />}
    renderSelectedIcon={() => <Icon color={'#6296f9'} name='whatshot' size={30} />}
    onPress={() => this.changeTab('feed')}>
    <Feed />
  </Tab>
  <Tab
    titleStyle={{fontWeight: 'bold', fontSize: 10}}
    selectedTitleStyle={{marginTop: -1, marginBottom: 6}}
    selected={selectedTab === 'profile'}
    title={selectedTab === 'profile' ? 'PROFILE' : null}
    renderIcon={() => <Icon containerStyle={{justifyContent: 'center', alignItems: 'center', marginTop: 12}} color={'#5e6977'} name='person' size={33} />}
    renderSelectedIcon={() => <Icon color={'#6296f9'} name='person' size={30} />}
    onPress={() => this.changeTab('profile')}>
    <Profile />
  </Tab>
  /* ... more tabs here */
</Tabs>

Hide Tab Bar

constructor () {
  super()
  this.state = {
    hideTabBar: true,
  }
}

hideTabBar(value) {
  this.setState({
    hideTabBar: value
  });
}

let tabBarStyle = {};
let sceneStyle = {};
if (this.state.hideTabBar) {
  tabBarStyle.height = 0;
  tabBarStyle.overflow = 'hidden';
  sceneStyle.paddingBottom = 0;
}

<Tabs hidesTabTouch tabBarStyle={tabBarStyle} sceneStyle={sceneStyle}>
  <Tab>
    <LoginView hideTabBar={this.hideTabBar.bind(this)} />
  </Tab>
  /* ... tabs here */
</Tabs>

Tabs Props

propdefaulttypedescription
sceneStyleinheritedobject (style)define for rendered scene
tabBarStyleinheritedobject (style)define style for TabBar
tabBarShadowStyleinheritedobject (style)define shadow style for tabBar
hidesTabTouchfalsebooleandisable onPress opacity for Tab

Tab Props

propdefaulttypedescription
renderIconnonefunctionreturns Item icon
renderSelectedIconnonefunctionreturns selected Item icon
badgeTextnonestring or numbertext for Item badge
renderBadgenonefunctionreturns Item badge
titlenonestringItem title
titleStyleinheritedstylestyling for Item title
selectedTitleStylenonestylestyling for selected Item title
tabStyleinheritedstylestyling for tab
selectednonebooleanreturn whether the item is selected
onPressnonefunctiononPress method for Item
allowFontScalingfalsebooleanallow font scaling for title

For issues or feature requests related to Tab Bar component please click here

HTML Style Headings

HTMLHeadings

<Text h1>Heading 1</Text>
<Text h2>Heading 2</Text>
<Text h3>Heading 3</Text>
<Text h4>Heading 4</Text>

Headings Props

propdefaulttypedescription
h1nonebooleanfont size 40 (optional)
h2nonebooleanfont size 34 (optional)
h3nonebooleanfont size 28 (optional)
h4nonebooleanfont size 22 (optional)
fontFamilynonestringfont family name (optional)
stylenoneobject (style)add additional styling for Text (optional)

ButtonGroup

ButtonGroup

Using strings

constructor () {
  super()
  this.state = {
    selectedIndex: 2
  }
  this.updateIndex = this.updateIndex.bind(this)
}
updateIndex (selectedIndex) {
  this.setState({selectedIndex})
}

render () {
  const buttons = ['Hello', 'World', 'Buttons']
  const { selectedIndex } = this.state
  return (
    <ButtonGroup
      onPress={this.updateIndex}
      selectedIndex={selectedIndex}
      buttons={buttons}
      containerStyle={{height: 100}} />
  )
}

Using components

constructor () {
  super()
  this.state = {
    selectedIndex: 2
  }
  this.updateIndex = this.updateIndex.bind(this)
}
updateIndex (selectedIndex) {
  this.setState({selectedIndex})
}

const component1 = () => <Text>Hello</Text>
const component2 = () => <Text>World</Text>
const component3 = () => <Text>ButtonGroup</Text>

render () {
  const buttons = [{ element: component1 }, { element: component2 }, { element: component3 }]
  const { selectedIndex } = this.state
  return (
    <ButtonGroup
      onPress={this.updateIndex}
      selectedIndex={selectedIndex}
      buttons={buttons}
      containerStyle={{height: 100}} />
  )
}

ButtonGroup props

This component inherits all native TouchableHighlight and TouchableOpacity props that come with React Native TouchableHighlight or TouchableOpacity elements, along with the following:
propdefaulttypedescription
selectedIndexnonenumbercurrent selected index of array of buttons (required)
onPressnonefunctionmethod to update Button Group Index (required)
buttonsnonearrayarray of buttons for component (required), if returning a component, must be an object with { element: componentName }
componentTouchableHighlightReact Native ComponentChoose other button component such as TouchableOpacity (optional)
containerStyleinherited stylingobject (style)specify styling for main button container (optional)
selectedBackgroundColorwhitestringspecify color for selected state of button (optional)
textStyleinherited stylingobject (style)specify specific styling for text (optional)
selectedTextStyleinherited stylingobject (style)specify specific styling for text in the selected state (optional)
underlayColorwhitestringspecify underlayColor for TouchableHighlight (optional)
borderStyleinherited stylingobject (style)update the styling of the interior border of the list of buttons (optional)

Checkboxes

Checkboxes

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

<CheckBox
  title='Click Here'
  checked={this.state.checked}
/>

<CheckBox
  center
  title='Click Here'
  checked={this.state.checked}
/>

<CheckBox
  center
  title='Click Here'
  checkedIcon='dot-circle-o'
  uncheckedIcon='circle-o'
  checked={this.state.checked}
/>

<CheckBox
  center
  title='Click Here to Remove This Item'
  iconRight
  iconType='material'
  checkedIcon='clear'
  uncheckedIcon='add'
  checkedColor='red'
  checked={this.state.checked}
/>

Checkbox props

This component uses FontAwesome icons out of the box. You can also specify one of the following types of icons by specifying an iconType prop: Simple Line Icon, Zocial, Octicons, MaterialIcons, MaterialCommunityIcons, Ionicons, Foundation, EvilIcons, or Entypo

propdefaulttypedescription
iconTypefontawesomestringicon family, can be one of the following: simple-line-icon, zocial, octicon, material, material-community, ionicon, foundation, evilicon, entypo (required only if specifying an icon that is not from font-awesome)
componentTouchableOpacityReact Native Componentspecify React Native component for main button (optional)
checkedfalsebooleanflag for checking the icon (required)
iconRightfalsebooleanmoves icon to right of text (optional)
rightfalsebooleanaligns checkbox to right (optional)
centerfalsebooleanaligns checkbox to center (optional)
titlenonestringtitle of checkbox (required)
containerStylenoneobject (style)style of main container (optional)
textStylenoneobject (style)style of text (optional)
onLongPressnonefunctiononLongPress function for checkbox (optional)
onPressnonefunctiononPress function for checkbox (required)
checkedIconcheck-square-ostringdefault checked icon (Font Awesome Icon) (optional)
uncheckedIconsquare-ostringdefault checked icon (Font Awesome Icon) (optional)
checkedColorgreenstringdefault checked color (optional)
uncheckedColor#bfbfbfstringdefault unchecked color (optional)
checkedTitlenonestringspecify a custom checked message (optional)
fontFamilySystem font bold (iOS), Roboto-Bold (android)stringspecify different font family

Forms

Forms

import { FormLabel, FormInput } from 'react-native-elements'

<FormLabel>Name</FormLabel>
<FormInput onChangeText={someFunction}/>
<FormValidationMessage>Error message</FormValidationMessage>

FormValidationMessage example

FormValidationMessage example

FormInput props

This component inherits all native TextInput props that come with a standard React Native TextInput element, along with the following:
propdefaulttypedescription
containerStylenoneobject (style)TextInput container styling (optional)
inputStylenoneobject (style)TextInput styling (optional)
textInputRefnonerefget ref of TextInput
containerRefnonerefget ref of TextInput container
focusnonefunctioncall focus on the textinput(optional), eg this.refs.someInputRef.focus()

FormLabel props

propdefaulttypedescription
containerStylenoneobject (style)additional label container style (optional)
labelStylenoneobject (style)additional label styling (optional)
fontFamilySystem font bold (iOS), Roboto-Bold (android)stringspecify different font family

FormValidationMessage props

propdefaulttypedescription
containerStylenoneobject (style)additional label container style (optional)
labelStylenoneobject (style)additional label styling (optional)
fontFamilySystem font bold (iOS), Roboto-Bold (android)stringspecify different font family

Using FormInput refs

<FormInput
  ref='forminput'
  textInputRef='email'
  ...
/>

You should be able to access the refs like this

this.refs.forminput.refs.email

Card

Card Component

const users = [
 {
    name: 'brynn',
    avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/brynn/128.jpg'
 },
 ... // more users here
]

import { Text } from 'react-native'
import { Card, ListItem, Button } from 'react-native-elements'

// implemented without image with header
<Card
  title='CARD WITH DIVIDER'>
  {
    users.map((u, i) => {}
  }
</Card>

// implemented without image without header, using ListItem component
 <Card containerStyle={{padding: 0}} >
  {
    users.map((u, i) => {
      return (
        <ListItem
          key={i}
          roundAvatar
          title={u.name}
          avatar={{uri:u.avatar}} />

      )
    })
  }
</Card>


// implemented with Text and Button as children
<Card
  title='HELLO WORLD'
  image={require('../images/pic2.jpg')}>
  <Text style={{marginBottom: 10}}>
    The idea with React Native Elements is more about component structure than actual design.
  </Text>
  <Button
    icon={{name: 'code'}}
    backgroundColor='#03A9F4'
    fontFamily='Lato'
    buttonStyle={{borderRadius: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}}
    title='VIEW NOW' />
</Card>

Card props

propdefaulttypedescription
flexDirectioncolumnstringflex direction (row or column) (optional)
containerStylenoneobject (style)outer container style (optional)
wrapperStylenoneobject (style)inner container style (optional)
titlenonestringoptional card title (optional)
titleStylenoneobject (style)additional title styling (if title provided) (optional)
dividerStylenoneobject (style)additional divider styling (if title provided) (optional)
fontFamilySystem font bold (iOS), Roboto-Bold (android)stringspecify different font family
imageStyleinherited stylingobject(style)specify image styling if image is provided
imagenoneimage uri or require pathadd an image as the heading with the image prop (optional)

Pricing Component

Pricing Component

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

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

PricingCard props

propdefaulttypedescription
titlenonestringtitle (required)
pricenonestringprice (required)
colornonestringcolor scheme for button & title (required)
infononearray of stringspricing information (optional)
buttonnoneobject {title, icon, buttonStyle}button information (required)
onButtonPressnoneanyfunction to be run when button is pressed
containerStyleinherited stylingobject (style)outer component styling (optional)
wrapperStyleinherited stylingobject (style)inner wrapper component styling (optional)
titleFontSystem font (font weight 800) (iOS), Roboto-Black (android)stringspecify title font family
pricingFontSystem font (font weight 700) (iOS), Roboto-Bold (android)stringspecify pricing font family
infoFontSystem font bold (iOS), Roboto-Bold (android)stringspecify pricing information font family
buttonFontSystem font (iOS), Roboto (android)stringspecify button font family

Grid Component

The Grid component provides two types of layouts, Row and Column. This provides you with an easy way to position your elements on screen without using flex directly.

This component was inspired from react-native-easy-grid by GeekyAnts. Check out NativeBase.io if you haven't already!

Row

import {Grid, Row} from 'react-native-elements';

<Grid>
  <Row></Row>
  <Row></Row>
</Grid>

Column

import {Grid, Col} from 'react-native-elements';

<Grid>
  <Col></Col>
  <Col></Col>
</Grid>

Creating nested layout

import {Grid, Col, Row} from 'react-native-elements';

<Grid>
  <Col></Col>
  <Col>
    <Row></Row>
    <Row></Row>
  </Col>
</Grid>

Using the size prop

A ratio can be passed to the Size Prop

<Grid>
  <Row size={3}></Row>
  <Row size={1}></Row>
</Grid>
<Grid>
  <Col size={75}></Col>
  <Col size={25}></Col>
</Grid>

GridComponent Props

propdefaulttypedescription
stylenoneobject (style)Outer grid styling (optional)
onPressnonefunctiononPress method (optional)
activeOpacity1numberOpacity on pressing (optional)

ColComponent Props

propsdefaulttypedescription
stylenoneobject (style)Styling for the outer column (optional)
sizenonenumberSize for column (optional)
onPressnonefunctiononPress method (optional)
activeOpacity1numberOpacity on pressing (optional)

RowComponent Props

propsdefaulttypedescription
stylenoneobject (style)Styling for the outer column (optional)
sizenonenumberSize for row (optional)
onPressnonefunctiononPress method (optional)
activeOpacity1numberOpacity on pressing (optional)

Slider Component

Slider Component

A pure JavaScript component for react-native. It is a drop-in replacement for Slider.

This component is a forked implementation of react-native-slider. Also note that due to the nature of the platform, and the existence of breaking changes between React Native releases, this implementation currently only supports v0.26.0+

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

<View style={{flex: 1, alignItems: 'stretch', justifyContent: 'center'}}>
  <Slider
    value={this.state.value}
    onValueChange={(value) => this.setState({value})} />
  <Text>Value: {this.state.value}</Text>
</View>

Slider Props

proptypeoptionaldefaultdescription
valuenumberYes0Initial value of the slider
disabledboolYesfalseIf true the user won't be able to move the slider
minimumValuenumberYes0Initial minimum value of the slider
maximumValuenumberYes1Initial maximum value of the slider
stepnumberYes0Step value of the slider. The value should be between 0 and maximumValue - minimumValue)
minimumTrackTintColorstringYes'#3f3f3f'The color used for the track to the left of the button
maximumTrackTintColorstringYes'#b3b3b3'The color used for the track to the right of the button
thumbTintColorstringYes'#343434'The color used for the thumb
thumbTouchSizeobjectYes{width: 40, height: 40}The size of the touch area that allows moving the thumb. The touch area has the same center as the visible thumb. This allows to have a visually small thumb while still allowing the user to move it easily.
onValueChangefunctionYesCallback continuously called while the user is dragging the slider
onSlidingStartfunctionYesCallback called when the user starts changing the value (e.g. when the slider is pressed)
onSlidingCompletefunctionYesCallback called when the user finishes changing the value (e.g. when the slider is released)
stylestyleYesThe style applied to the slider container
trackStylestyleYesThe style applied to the track
thumbStylestyleYesThe style applied to the thumb
debugTouchAreaboolYesfalseSet this to true to visually see the thumb touch rect in green.
animateTransitionsboolYesfalseSet to true if you want to use the default 'spring' animation
animationTypestringYes'timing'Set to 'spring' or 'timing' to use one of those two types of animations with the default animation properties.
animationConfigobjectYesundefinedUsed to configure the animation parameters. These are the same parameters in the Animated library.

Tile Component

A component with full size image and with text either inside the image or under the image along with customizable caption

This component was inspired from Shoutem UI by Shoutem. Check out Shoutem if you haven't already!

Featured Tile

screen shot 2017-01-15 at 9 50 15 pm

<Tile
   imageSrc={{require: ('./img/path')}}
   title="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores dolore exercitationem"
   featured
   caption="Some Caption Text"
/>

Featured Tile with Icon

screen shot 2017-01-15 at 9 50 22 pm

<Tile
  imageSrc={{require: ('./img/path')}}
  icon={{name: 'play-circle', type: 'font-awesome'}}
  featured
/>

Tile with Icon

screen shot 2017-01-15 at 9 50 34 pm

<Tile
  imageSrc={{require: ('./img/path')}}
  title="Lorem ipsum dolor sit amet, consectetur"
  icon={{name: 'play-circle', type: 'font-awesome'}}  // optional
  contentContainerStyle={{height: 70}}
>
  <View style={{flex: 1, flexDirection: 'row', justifyContent: 'space-between'}}>
    <Text>Caption</Text>
    <Text>Caption</Text>
  </View>
</Tile>

Tile Props

propdefaulttypedescription
iconnoneobject {name: string, color: string, size: number, type: string (default is material, or choose one of material-community, simple-line-icon, zocial, font-awesome, octicon, ionicon, foundation, evilicon, or entypo), iconStyle: object(style)}Icon Component Props (optional)
iconContainerStylenoneobject (style)Styling for the outer icon container (optional)
titlenonestringText inside the tile (optional)
titleStylenoneobject (style)Styling for the title (optional)
captionnonestringText inside the tilt when tile is featured
captionStylenoneobject (style)Styling for the caption (optional)
featuredfalsebooleanChanges the look of the tile (optional)
containerStylenoneobject (style)Styling for the outer tile container (optional)
imageSrcnoneobject (image)Source for the image (required)
imageContainerStylenoneobject (style)Styling for the image (optional)
onPressnonefunction (event)Function to call when tile is pressed (optional)
activeOpacity0.2numberNumber passed to control opacity on press (optional)
contentContainerStylenoneobject (style)Styling for bottom container when not featured tile (optional)
widthDevice WidthnumberWidth for the tile (optional)
heightDevice Width * 0.8numberHeight for the tile