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
Type | Object |
---|
Description
An object with useful properties for controlling the state of a Toast
component and its associated items.
resources.addToast
Type | Function |
---|---|
Param | props.delay number - Sets the number of milliseconds to wait before automatically calling the onClose function. onClose should be passed by props. |
Param | props.title string - Sets the title. The function useToast receives an empty object. In order to use it, you must provide the title and message props. |
Param | props.message string | 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. |
Param | props.size Toast.sizes.SM | Toast.sizes.MD - Sets the font size. The default value for this property is Toast.sizes.SM |
Param | props.kind Toast.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 |
Param | props.onClose function - Callback fired when the Toast closure is requested. |
Param | props.onRemoved function - Callback fired after the Toast is closed. |
Param | props.irremovable bool - 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
Type | Function |
---|---|
Param | key String | Number - Toast identificator. You should inform the key from the Toasts array. |
Description
Remove an indicated toast.