Skip to content

Latest commit

 

History

History
128 lines (119 loc) · 3.55 KB

Toast.md

File metadata and controls

128 lines (119 loc) · 3.55 KB

toast-def-headref

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.

Replacing Component: React Native View.

Preview ios toast-def-headref Preview android toast-def-headref

Contents:

Syntax

import { Root } from "native-base";
import { StackNavigator } from "react-navigation";
const AppNavigator = StackNavigator(
  {
    Page: { screen: Page },
  }
);
export default () =>
  <Root>
    <AppNavigator />
  </Root>;
import React, { Component } from 'react';
import { Container, Header, Content, Toast, Button, Text } 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!',
              buttonText: 'Okay'
            })}>
            <Text>Toast</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}

Configuration

Key Value Option Description
text - string Text content to be shown in the toast
textStyle - - Style text content for toast
buttonText - string, blank Text to be displayed inside the button
buttonTextStyle - - Style button text for toast
buttonStyle - - Style button for toast
position bottom top, bottom Sets position for the toast
type - danger, success, warning Sets context to the Toast
duration 1500 user defined (integer) Milliseconds after which Toast disappers
onClose - function Called just before the toast hides