Skip to content

Latest commit

 

History

History
96 lines (88 loc) · 2.67 KB

Toast.md

File metadata and controls

96 lines (88 loc) · 2.67 KB

Toast

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

For Toast to work, you need to wrap your topmost component inside <Root> from native-base.

import { Root } from "native-base";
import { StackNavigator } from "react-navigation";
const AppNavigator = StackNavigator(
  {
    Page: { screen: Page },
  }
);
export default () =>
  <Root>
    <AppNavigator />
  </Root>;

Preview ios Toast Preview android Toast

Syntax

import React, { Component } from 'react';
import { Container, Header, Content, Toast, Button, Text, Icon } from 'native-base';
export default class ToastExample extends Component {
  constructor(props) {
    super(props);
    this.state = {
      showToast: false
    }
  }
  render() {
    return (
      <Container>
        <Header />
        <Content padder>
          <Button onPress={()=> Toast.show({
              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 Sets position for the toast.
type - danger,success,warning Sets context to the Toast.
duration - integer Milliseconds after which Toast disappers