aliceui v1.0.0
AliceUI
Beautiful Material UI for React Native
- Installation
- Getting started
- AliceUI skeleton
- Components - Buttons - Raised Button - Colored Button - Button Icon - Flat button - FAB - Chips - Toolbar - Cards - Card - CardContent - Lists - List - ListItem - ListDivider - ListSubheader - Drawer - Drawer - DrawerHeader
- Colors
- icon vs iconName
Installation
Just use npm as always:
npm install --save aliceui
Getting started
Importing a component
There are two ways to import a component in AliceUI, one of those is:
import React, {Component} from 'react'
import {Toolbar} from 'aliceui'
The other way is:
import Toolbar from 'aliceui/Toolbar'
Easy, don't you think? Be careful: There are some components that use importing as object even if imported from himself. e.g:
import {RaisedButton} from 'aliceui' //ok
import RaisedButton from 'aliceui/Button' //won't work
import {RaisedButotn} from 'aliceui/Button' //work as a charm
But don't worry, all these peculiar components are listed in the docs down below.
AliceUI skeleton
An AliceUI application have the components structure like this:
import React, {Component} from 'react'
import {Container, Content} from 'aliceui'
class App extends Component {
render () {
return (
<Container>
<Toolbar />
<Content>
// Your content
</Content>
</Container>
)
}
}
Or if you have a Drawer in your application:
import {Container, Content, Drawer} from 'aliceui'
class App extends Component {
render () {
return (
<Drawer>
<Container>
<Toolbar />
<Content>
// Your content
</Content>
</Container>
</Drawer>
)
}
}
The Content have a propertie called padding, which when is set to true, it makes a margin from the borders of the device (it's not a required propertie).
Components
Buttons
https://material.io/guidelines/components/buttons.html
Raised Button
import React, {Component} from 'react'
import {Content} from 'aliceui'
import {RaisedButton} from 'aliceui'
class Button extends Component {
render () {
return (
<Content padding>
<RaisedButton label="Alice Rocks" />
<RaisedButton label="Alice Rocks" full />
<RaisedButton label="Alice Rocks" disabled />
</Content>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
label | The text showed in the button | String | Yes | null |
full | The button get 100% of width | Boolean | No | false |
disabled | Will disable the button | Boolean | No | false |
onPress | Function to be executed when press | Function | No | null |
style | Optional styles | Object | No | null |
Colored Button
import React, {Component} from 'react'
import {Content} from 'aliceui'
import {ColoredButton} from 'aliceui'
import Colors from 'aliceui/Colors'
export default class extends Component {
render () {
return (
<Content padding>
<ColoredButton label="Alice Rocks" />
<ColoredButton label="Alice Rocks" full />
<ColoredButton label="Alice Rocks" color={Colors.Blue} />
<ColoredButton label="Alice Rocks" disabled />
</Content>
)
}
}
A bit confused about Colors? Read more here.
Properties
name | description | type | required | default |
---|---|---|---|---|
label | The text showed in the button | String | Yes | null |
full | The button get 100% of width | Boolean | No | false |
disabled | Will disable the button | Boolean | No | false |
onPress | Function to be executed when press | Function | No | null |
color | Pass a color scheme to the button | aliceui.Color | No | Pink |
style | Optional styles | Object | No | null |
Button icon
import React, {Component} from 'react'
import Icon from 'react-native-vector-icons/MaterialIcons'
import {Content} from 'aliceui'
import {ButtonIcon} from 'aliceui'
import Colors from 'aliceui/Colors'
export default class extends Component {
render () {
return (
<Content padding>
<ButtonIcon iconName="star" />
<ButtonIcon iconName="menu" color={Colors.LightGreen} />
<ButtonIcon iconName="star" disabled />
</Content>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
disabled | Will disable the button | Boolean | No | false |
onPress | Function to be executed when press | Function | No | null |
color | Pass a color scheme to the button | aliceui.Color | No | Pink |
iconName | Name of the icon (Google Material Icons) | String | No | null |
icon | An icon to be rendered | Component | No | null |
style | Optional styles | Object | No | null |
Learn the difference between iconName and icon.
Flat button
import React, {Component} from 'react'
import {Content} from 'aliceui'
import {FlatButton} from 'aliceui'
import Colors from 'aliceui/Colors'
export default class extends Component {
render () {
return (
<Content padding>
<FlatButton label="Alice Rocks" />
<FlatButton label="Alice Rocks" noInk />
<FlatButton label="Alice Rocks" full />
<FlatButton label="Alice Rocks" color={Colors.Blue} />
<FlatButton label="Alice Rocks" disabled />
</Content>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
label | The text showed in the button | String | Yes | null |
full | The button get 100% of width | Boolean | No | false |
disabled | Will disable the button | Boolean | No | false |
onPress | Function to be executed when press | Function | No | null |
color | Pass a color scheme to the button | aliceui.Color | No | Pink |
noInk | Remove the ink of the button | Boolean | No | false |
style | Optional styles | Object | No | null |
FAB
import React, {Component} from 'react'
import {Container, Content} from 'aliceui'
import {FAB} from 'aliceui'
import Colors from 'aliceui/Colors'
export default class extends Component {
render () {
return (
<Container>
<Content padding>
<FAB iconName="star" />
<FAB iconName="person" color={Colors.Red} />
<FAB iconName="person" disabled />
</Content>
<FAB fixed="left" iconName="add" />
<FAB fixed="right" iconName="person" />
</Container>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
disabled | Will disable the button | Boolean | No | false |
onPress | Function to be executed when press | Function | No | null |
color | Pass a color scheme to the button | aliceui.Color | No | Pink |
iconName | Name of the icon (Google Material Icons) | String | No | null |
icon | An icon to be rendered | Component | No | null |
style | Optional styles | Object | No | null |
fixed | "left" or "right" (element must be outside the Content) | String | No | null |
Chips
https://material.io/guidelines/components/chips.html
import React, {Component} from 'react'
import {Content} from 'aliceui'
import Chip from 'aliceui/Chip'
export default class extends Component {
render () {
return (
<Content padding>
<Chip label="Banana" />
<Chip label="Banana" subLabel="(fruit)" />
</Content>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
label | The text inside the chip | String | Yes | null |
subLabel | "Description" of the chip | String | No | null |
onDeleteChip | When the delete button is pressed | Function | No | null |
style | Optional styles | Object | No | null |
Toolbar
https://material.io/guidelines/components/toolbars.html
import React, {Component} from 'react'
import {Container} from 'aliceui'
import {ButtonIcon} from 'aliceui/Button'
import Toolbar from 'aliceui/Toolbar'
class ToolbarLeftContent extends Component {
render () {
return (
<ButtonIcon iconName="menu" />
)
}
}
class ToolbarRightContent extends Component {
render () {
return (
<ButtonIcon iconName="more-vert" />
)
}
}
export default class extends Component {
render () {
return (
<Container>
<Toolbar title="Alice" leftContent={<ToolbarLeftContent />} rightContent={<ToolbarRightContent />} />
</Container>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
title | The title to be showed in the bar | String | No | null |
leftContent | The left content of the bar | Component | No | null |
rightContent | The right content of the bar | Component | No | null |
color | Pass a color scheme to the bar | aliceui.Color | No | Pink |
Avatars
https://material.io/guidelines/style/imagery.html
import React, {Component} from 'react'
import {Content} from 'aliceui'
import Avatar from 'aliceui/Avatar'
export default class extends Component {
render () {
return (
<Content padding>
<Avatar imageUri="http://i.imgur.com/G7LVv13.jpg" />
<Avatar imageUri="http://i.imgur.com/G7LVv13.jpg" small />
</Content>
)
}
}
Properties
name | description | type | required | default |
---|---|---|---|---|
imageUri | The URI of the image | String | Yes | null |
small | A tiny avatar | Boolean | No | false |
Cards
https://material.io/guidelines/components/cards.html
import React, {Component} from 'react'
import {Text} from 'react-native'
import {Content} from 'aliceui'
import {ButtonIcon, FlatButton} from 'aliceui/Button'
import Colors from 'aliceui/Colors'
import {Card, CardImage, CardContent, CardFooter} from 'aliceui/Card'
class CardActions extends Component {
render () {
return (
<ButtonIcon iconName="share" />
)
}
}
export default class extends Component {
render () {
return (
<Content padding>
<Card>
<CardContent>
<Text>Hello World!</Text>
</CardContent>
<CardFooter />
</Card>
<Card background={true} color={Colors.LightGreen}>
<CardContent>
<Text>Hello World!</Text>
</CardContent>
<CardFooter />
</Card>
<Card>
<CardImage imageUri="http://i.imgur.com/8Sxl6GQ.jpg" title="Welcome" style={{height: 156}} actions={<CardActions />} />
<CardContent>
<Text>Hello World!</Text>
</CardContent>
<CardFooter>
<FlatButton label="Ok" />
</CardFooter>
</Card>
</Content>
)
}
}
Card
Properties
name | description | type | required | default |
---|---|---|---|---|
background | Set the current theme color as background | Boolean | No | false |
color | Pass a color scheme to the card | aliceui.Color | No | Pink |
style | Optional styles | Object | No | null |
CardImage
Properties
name | description | type | required | default |
---|---|---|---|---|
imageUri | Set the current theme color as background | Boolean | No | false |
cardActions | Actions to be displayed in the card | Component | No | null |
title | The title of the card | String | No | null |
style | Height of the image + optional styles | Object | No | null |
Lists
https://material.io/guidelines/components/lists.html
import React, {Component} from 'react'
import {Text} from 'react-native'
import {Content} from 'aliceui'
import {List, ListItem, ListDivider, ListSubheader} from 'aliceui/List'
class ListItemRightContent extends Component {
render () {
return (
<Text>100</Text>
)
}
}
export default class extends Component {
render () {
return (
<Content padding>
<List>
<ListItem label="Cat" />
<ListItem label="Dog" rightContent={<ListItemRightContent />} />
</List>
<ListDivider />
<List>
<ListSubheader label="Fruits" />
<ListItem label="Orange" active />
<ListItem label="Apple" leftIconName="star" />
</List>
</Content>
)
}
}
ListItem
Properties
name | description | type | required | default |
---|---|---|---|---|
label | The text of the item | String | Yes | null |
leftContent | The left content of the item | Component | No | null |
rightContent | The right content of the item | Component | No | null |
active | Set active style to the item | Boolean | No | null |
leftIconName | Name of the left icon (Google Material Icons) | String | No | null |
rightIconName | Name of the right icon (Google Material Icons) | String | No | null |
onPress | Function to be executed when press | Function | No | null |
ListSubheader
Properties
name | description | type | required | default |
---|---|---|---|---|
label | The text of the subheader | String | Yes | null |
Drawer
https://material.io/guidelines/patterns/navigation-drawer.html
import React, {Component} from 'react'
import {Container, Content} from './aliceui'
import {ButtonIcon} from './aliceui/Button'
import {Drawer, DrawerHeader} from './aliceui/Drawer'
import {List, ListItem} from './aliceui/List'
import Toolbar from './aliceui/Toolbar'
class ToolbarLeftContent extends Component {
render () {
return (
<ButtonIcon iconName="menu" onPress={this.props.onPressButton} />
)
}
}
class DrawerContent extends Component {
render () {
return (
<Content>
<DrawerHeader backgroundUri="http://i.imgur.com/4fnXwrW.png" avatarImageUri="http://i.imgur.com/G7LVv13.jpg" name="Hélio" email="heliojuniorkroger@gmail.com" />
<List>
<ListItem label="Home" active />
<ListItem label="News" />
<ListItem label="Logout" />
</List>
</Content>
)
}
}
export default class extends Component {
constructor () {
super()
this.state = {
drawerOpen: false
}
}
openDrawer () {
this.setState({
drawerOpen: true
})
}
render () {
return (
<Drawer open={this.state.drawerOpen} content={<DrawerContent />}>
<Container>
<Toolbar title="Alice" leftContent={<ToolbarLeftContent onPressButton={() => this.openDrawer()} />} />
<Content>
</Content>
</Container>
</Drawer>
)
}
}
Drawer
Properties
name | description | type | required | default |
---|---|---|---|---|
open | Define the drawer state | Boolean | No | false |
content | The content of the drawer | Component | No | null |
DrawerHeader
Properties
name | description | type | required | default |
---|---|---|---|---|
backgroundUri | Uri of the background image | String | No | null |
avatarImageUri | Uri of the avatar image | String | No | null |
name | Name to be displayed | String | No | null |
Email to be displayed | String | No | null |
Colors
https://material.io/guidelines/style/color.html
AliceUI have the complete palette of colors from Material Design. You need to import aliceui/Colors to access them. To get a color scheme you just need to pass the value to the imported variable Colors. e.g: Colors.Yellow.
icon vs iconName
AliceUI uses react-native-vector-icons to use Google's Material Icons inside the code. When you use the property iconName you're accessing the MaterialIcons pack from react-native-vector-icons. On the other hand, if you use icon, you need to pass the whole icon component (probably imported from react-native-vector-icons).
7 years ago