Skip to main content

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#

import { useNotification } from 'tailor-ui';

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) => void
  • notification.destroy: () => void

Config#

ArgumentTypeDefaultDescription
keystring-key of the notification
iconReactNode-icon of the notification
contentReactNode-content of the notification
durationnumberInfinitytime(ms) before auto-dismiss.