Socket
Socket
Sign inDemoInstall

react-native-tiny-toast

Package Overview
Dependencies
3
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-tiny-toast

😊A react native toast like component , it works on IOS and Android.


Version published
Weekly downloads
925
decreased by-4.84%
Maintainers
1
Install size
204 kB
Created
Weekly downloads
 

Readme

Source

react-native-tiny-toast

A react native toast like component , it works on IOS and Android.

release PRs Welcome NPM version License MIT

Features
  1. Support iPhone X, XS, XS Max & XR
  2. Support both Android and IOS.
  3. Custom icon and style and so on.
  4. Use native ActivityIndicator.

Demo

Screenshots

Install

npm i react-native-tiny-toast --save
or
yarn add react-native-tiny-toast

Getting started

import Toast from 'react-native-tiny-toast'

Toast.show('This is a default toast')

Toast.showSuccess('Pay success')

Toast.show('Custom toast',{
  position: Toast.position.center,
  containerStyle:{},
  textStyle: {},
  imgSource: require('xxx'),
  imgStyle: {},
  mask: true,
  maskStyle:{},
  ...
})

const toast = Toast.showLoading('Loading...')
setTimeout(() => {
  // Recommend
  Toast.hide(toast) 
  // or Toast.hide()
  // If you don't pass toast,it will hide the last toast by default.
 }, 3000)
    
Using a Component
import React, {Component} from 'react-native'
import Toast from 'react-native-tiny-toast'

class Example extends Component {
    state={
      visible: false
    }
    
    componentDidMount() {
        setTimeout(() => this.setState({
            visible: true
        }), 1000); 

        setTimeout(() => this.setState({
            visible: false
        }), 3000);
    };

    render() {
        return 
        <Toast
            visible={this.state.visible}
            position={50}
            onHidden={()=>{
              // onHidden
            }}>This is a message
        </Toast>
    }
}

Api

NameDefaultTypeDescription
containerStylenullViewPropTypes.styleCustom container style
durationToast.durations.SHORTNumberToast duration(ms), won't disappear if value is 0
delay0NumberThe delay duration before toast start appearing on screen.
animationDuration200NumberAnimation duration
visiblefalseBooleanShow toast. (Only for Toast Component)
positionToast.position.bottomNumber0 means the middle of the screen.A negative number indicates the distance to the bottom of the screen.A positive number indicates the distance to the top of the screen.
animationtrueBooleanWhether to enable fade animation
shadowfalseBooleanWhether to enable shadow
shadowColor#000StringShadow color(don't support android)
showTexttrueBooleanWhether to show text
textColor#fffStringText color
textStylenullText.propTypes.styleText style
maskfalse(true when showLoading)BooleanWhether to enable mask
maskColorrgba(0,0,0,0.3)StringMask background color
maskStylenullViewPropTypes.styleMask style
imgSourcenullImage.sourceImage source
imgStylenullImage.propTypes.styleImage style
loadingfalse(true when showLoading)BooleanWhether to show loading
indicatorSizelargeString or NumberSet the ActivityIndicator size,Currently only specific values can be set on Android.
onHiddennullFunctionTriggered when toast's hide animation end
onMaskPressnullFunctionTriggered when the mask is clicked
MethodTypeDescription
show(text, options)FunctionShow a toast
showSuccess(text, options)FunctionShow a toast with success icon
showLoading(text, options)FunctionShow a toast with ActivityIndicator
hide(toast)FunctionIf you don't pass toast,it will hide the last toast by default.

MIT Licensed

Keywords

FAQs

Last updated on 21 Feb 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc