Pular para o conteúdo principal

useToast

A hook that makes it possible to add more than one Toast, to remove one or more of them, and to clear them all.

Import

import { useToast } from '@resultadosdigitais/tangram-components'

Returns

resources

TypeObject

Description

An object with useful properties for controlling the state of a Toast component and its associated items.

resources.addToast

TypeFunction
Paramprops.delaynumber- Sets the number of milliseconds to wait before automatically calling the onClose function. onClose should be passed by props.
Paramprops.titlestring- Sets the title. The function useToast receives an empty object. In order to use it, you must provide the title and message props.
Paramprops.messagestring | node- Sets if the Toast content will be customizable. The function useToast receives an empty object. In order to use it, you must provide the title and message props.
Paramprops.sizeToast.sizes.SM | Toast.sizes.MD- Sets the font size. The default value for this property is Toast.sizes.SM
Paramprops.kindToast.kinds.default | Toast.kinds.primary | Toast.kinds.success | Toast.kinds.danger | Toast.kinds.warning | Toast.kinds.help- Sets the kind for styling. The default value for this property is Toast.kinds.default
Paramprops.onClosefunction- Callback fired when the Toast closure is requested.
Paramprops.onRemovedfunction- Callback fired after the Toast is closed.
Paramprops.irremovablebool- If true, the close button will be hidden. The default value for this property is false.

Description

Add a new toast above the former one.

resources.removeToast

TypeFunction
ParamkeyString | Number- Toast identificator. You should inform the key from the Toasts array.

Description

Remove an indicated toast.

resources.clean

TypeFunction

Description

Remove all added toasts.

resources.toasts

TypeArray<Object>

Description

Return all toasts with their props.

Feedback