Notification
Display a notification message globally.
When To Use#
To display a notification message at any of the four corners of the viewport. Typically it can be used in the following cases:
- A notification with complex content.
- A notification providing a feedback based on the user interaction. Or it may show some details about upcoming steps the user may have to follow.
- A notification that is pushed by the application.
Examples#
Basic#
Manual close by hooks return value#
Manual close by key#
Destroy all notification#
With icon#
Customized duration#
Handle Promise#
API#
Methods#
notification.open: (config) => [Promise, closeFn]notification.close: (key: string) => voidnotification.destroy: () => void
Config#
| Argument | Type | Default | Description |
|---|---|---|---|
| key | string | - | key of the notification |
| icon | ReactNode | - | icon of the notification |
| content | ReactNode | - | content of the notification |
| duration | number | Infinity | time(ms) before auto-dismiss. |