JGuang

Notification

Notification · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Notification

Display a notification message globally.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: The simplest usage.
  • Type: There are 5 different types of Notification: info, success, warning, error, normal.
  • Update: Specifying id to update the existing notification.
  • Update duration: Specifying id to update the existing notification's duration.
  • Custom action buttons: You can add operation buttons by specifying the btn field.
  • Customize style: You can set style and className to customize the style.
  • Position: Notification has 4 different positions, Top Left, Top Right (default), Bottom Left, Bottom Right.
  • Hooks - Usage: You can use useNotification to create a dialog that can read the context.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Notification

PropertyDescriptionTypeDefaultValueVersion
closableWhether to show the close buttonbooleantrue-
showIconWhether to show the iconbooleantrue-
durationAutomatic shutdown time, the unit is msnumber3000-
idThe unique identifier of the current notification, which can be used to update the messagestring--
positionThe position of the message'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'--
btnAdd action buttonReactNode--
closeIconCustom the close button on top-right of the drawer dialogReactNode-2.50.0
iconCustom iconReactNode--
classNameAdditional css classstring | string[]--
contentNotification contentReactNode | string (Required)--
styleAdditional styleCSSProperties--
titleNotification titleReactNode | string--
onCloseCallback when close() => void--

Methods

  • Notification.info(config)
  • Notification.success(config)
  • Notification.warning(config)
  • Notification.error(config)
  • Notification.normal(config)
  • Notification.remove(id)
  • Notification.clear()

Global config

Notification.config(options)

PropertyDescriptionTypeDefault
maxCountMaximum number of notificationsnumber-
getContainerContainer of the notification() => HTMLElement() => document.body
durationThe time when the notification is automatically closednumber3000
prefixClsClassName prefixstringarco