Skip to content

Latest commit

 

History

History
122 lines (116 loc) · 3.74 KB

Toast.md

File metadata and controls

122 lines (116 loc) · 3.74 KB

Toast

NativeBase Toast can be used to display quick warning or error messages.

Preview ios Toast Preview android Toast

Syntax

import React, { Component } from 'react';
import { Container, Content, Toast, Button, Text, Header, Left, Right, Body, Title, Icon } from 'native-base';
export default class Toast extends Component {
  constructor(props) {
  super(props);
  this.state = {
    showToast: false
  }
}
render() {
  return (
      <Container>
        <Header>
          <Left>
            <Button transparent>
              <Icon name="arrow-back" />
            </Button>
          </Left>
          <Body>
            <Title>Hello</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Button onPress={()=> Toast.show({
              supportedOrientations: ['portrait','landscape'],
              text: 'Wrong password!',
              position: 'bottom',
              buttonText: 'Okay'
            })}>
            <Text>Toast</Text>
          </Button>
        </Content>
      </Container>
  );
}
}

Configuration

Key Value Option Description
text - string The text content to be shown in the toast.
buttonText - string The text to be displayed inside the button.
position bottom top,bottom,center Sets position for the toast.
type - danger,success,warning Sets context to the Toast.
duration - integer Milliseconds after which Toast disappers
supportedOrientations - Portrait, Landscape, Landscape-left, Landscape-right Allows the modal to be rotated to any of the specified orientations
style - - Attach any style to toast component.
buttonTextStyle - - Attach any style to toast Button Text.
buttonStyle - - Attach any style to toast Button.
textStyle - - Attach any style to toast Text component.

Note: For Toast to work, it has to be called inside Container.