Material Bread
v0.2.10
Home
Getting Started
React Native
Web
Electron
MacOS
Windows
NextJs
Expo
Vue Native
Style
Font
Icons
Theme
Components
Appbar
Searchbar
Appbar Bottom
Avatar
Backdrop
Badge
Banner
Bottom Navigation
Bottom Navigation Item
Button
Card
CardActions
CardContent
CardHeader
CardMedia
Checkbox
Chip
DataTable
DataTableCell
DataTableHeader
DataTablePagination
DataTableRow
Dialog
Divider
Drawer
DrawerHeader
DrawerItem
DrawerSection
DrawerBottom
Fab
Speed dial
Icon
IconButton
List
ListExpand
ListItem
ListSection
Menu
MenuItem
Paper
Progress Bar
Progress Circle
Radio Button
Ripple
Select
SheetBottom
SheetSide
Slider
Snackbar
SwipeNav
Switch
Tabs
Tab
Textfield
Searchfield
ToggleButton
ToggleButtonGroup
Tooltip
Typography
Utils
Anchor
Color
Hoverable
Shadow
Storybook
Showcase
Contributing
Library
Docs
About

Appbar Top

The top app bar displays information and actions relating to the current screen. - Material Docs

import { Appbar } from 'material-bread';

Component #

Appbar s are essentially broken into three parts: navigation , title , and actionItems . Many combinations are possible using these sections, but if you need more customization you can replace all of them by passing children .
Page Title
77
Live Editing
 <Appbar
    barType={"normal"}
    title={'Page Title'} 
    navigation={'menu'}
    onNavigation={() => console.log('onNavigation!')}
    actionItems={[
    <Badge
        containerStyle={{marginRight: 16, flex: 1}}
        color={'#e10050'}
        textColor={'white'}
        size={14}
        content={77}>
        <IconButton name="favorite" size={24} color={'white'} />
    </Badge>,
    {name: 'search', onPress: () => console.log('onSearch')},
    {name: 'more-vert'},
    ]}
/>

Usage #

Usage depends entirely on what kind of navigation you are using in your app. For example, in react-navigation you can replace the entire header with a custom appbar.
import React, { Component } from 'react';
import { View } from 'react-native';
import { Appbar } from 'material-bread';

export default class Header extends Component {
  render() {
    return (
      <View style={styles.header}>
        <Appbar title={'Page Title'} />
      <View>
    );
  }
}

Props #

Usage depends entirely on what kind of navigation you are using in your app. For example, in react-navigation you can replace the entire header with a custom appbar.
Name
Description
Type
Default
actionItems
Each can be an object or node, renders on the right
array
actionItemsStyle
Styles the container around the actionItems
object || array
barType
Type of appbar, other components change based on type
string: regular, prominent, dense, prominent dense
regular
backgroundImage
Renders image element as background
node
color
Component's background color
string
primary
elevation
Shadow on container appbar
number
8
onNavigation
OnPress for navigation IconButton if provided.
func
onTitle
OnPress for title string if provided.
func
navigation
Renders IconButton if string, or renders custom node on left of title
node || string
position
CSS position values applied to root appbar
string: fixed, relative, absolute
relative
subtitle
Only displays on barType prominent, under the Title
string
subtitleStyles
Styles Subtitle
object
title
Displays on the left after navigation. If string it follows guidelines
string || node
titleStyles
Styles title if provided as string
object
style
Styles root element
object

Demos #

You can see even more examples in the Storybook environment.

Background image #

You must pass in an Image component, please read the React Native docs on Images to get a better idea of how to pass in images. Generally they are only used for prominent bars, but can be used on other types.
Background image
Live Editing
<Appbar
  barType={'prominent'}
  title={'Background image'}
  color={'#9C27B0'}
  navigation={'menu'}
  backgroundImage={
    <Image
      source={{
        uri:
          "https://images.pexels.com/photos/355465/pexels-photo-355465.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
      }}/>
    }
/>

Searchfield #

You can add a Searchfield or any other component directly in the Appbar
Page Title
Live Editing
 
class Header extends React.Component {
  constructor() {
    super();
    this.state = {
      isSearching: false,
      value: ''
    };
  }

  render() {
    return (
      <Appbar
        title={'Page Title'} 
        navigation={'menu'}
        actionItems={[
          <Searchfield 
            style={{
              marginHorizontal: 24, 
              flexGrow: this.state.isSearching ? 1 : 0,
              flexShrink: 0
            }}
            primary
            value={this.state.value}
            onChangeText={(value) => this.setState({value})}
            onFocus={() => this.setState({isSearching: true})}
            onBlur={() => this.setState({isSearching: false})}
            onCloseIcon={() => this.setState({value: ''})}
          />,

          {name: 'favorite'},
          <IconButton name="more-vert" size={24} color={'white'} />, 
        ]}
        navigation={'close'}
      />
    );
  }
}

Subtitle #

Subtitles can be used on normal or prominent barType s, but not dense . Try changing barType to normal to see how it will display
Page Title
Subtitle
Live Editing
<Appbar
  barType={'prominent'}
  title={'Page Title'} 
  subtitle={'Subtitle'}
  navigation={'menu'}
  actionItems={[
    {name: 'favorite'},
    {name: 'search', onPress: () => console.log('onSearch')},
    <IconButton name="more-vert" size={24} color={'white'} />, 
  ]}
/>

Custom #

Adding children will replace all internal components with the provided components.
HOME
INSTALL
DOCS
ABOUT
BUY
Live Editing
const styles = {
  appbar: {
    alignItems: 'center', 
    justifyContent:'space-between', 
    height: 60, 
    paddingVertical: 0, 
    paddingHorizontal: 8,
    backgroundColor: 'black',
    overflowX: 'auto'
  },
  left: {
    flexDirection: 'row', 
    alignItems: 'center', 
    justifyContent:'flex-start',
  },
  button: {
    height: 30, 
    alignSelf: 'center', 
    marginRight: 16
  },
}
  
render(
  <Appbar style={styles.appbar}>
  <View style={styles.left}>
    <Button text={'Home'} textColor="white" style={styles.button} />
    <Button text={'Install'} textColor="white" style={styles.button} />
    <Button text={'Docs'} textColor="white" style={styles.button} />
    <Button text={'About'} textColor="white" style={[styles.button, {marginRight: 0}]} />
  </View>
  <Button text={'Buy'} type={'contained'} textColor="white" containerStyle={[styles.button, {marginRight: 0}]} />
  </Appbar>
)
  • Menu item 1
    Menu item 2
    Menu item 3