Skip to main content
Version: 3.x

Taro.showToast(option)

Displays the message prompt box.

Note

  • Either Taro.showLoading or Taro.showToast can be displayed.
  • Taro.showToast should be paired with Taro.hideToast.

Reference

Type

(option: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
titlestringYesPrompt content
complete(res: CallbackResult) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
durationnumberNoThe delay time for a prompt
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
icon"success" | "loading" | "none"NoIcon
imagestringNoThe local path of the custom icon. image has priority over icon.
maskbooleanNoIndicates whether to display a transparent mask to prevent touch penetration
success(res: CallbackResult) => voidNoThe callback function for a successful API call

Sample Code

Taro.showToast({
title: 'Success',
icon: 'success',
duration: 2000
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.showToast✔️✔️✔️