Socket
Socket
Sign inDemoInstall

rc-notification

Package Overview
Dependencies
11
Maintainers
7
Versions
72
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-notification

notification ui component for react


Version published
Maintainers
7
Weekly downloads
1,107,927
decreased by-7.1%

Weekly downloads

Package description

What is rc-notification?

The rc-notification package is a React component library for generating and managing notifications in a web application. It allows developers to easily display notifications or alerts to users, with customizable content, styles, and behaviors.

What are rc-notification's main functionalities?

Creating and displaying a notification

This feature allows developers to create and display a notification with a title, description, and an onClick event handler. The notification appears on the screen and can be interacted with by the user.

notification.open({
  message: 'Notification Title',
  description: 'This is the content of the notification.',
  onClick: () => {
    console.log('Notification Clicked!');
  }
});

Customizing notification duration

This code sample demonstrates how to set a custom duration for a notification, in seconds. After the specified time, the notification will automatically close.

notification.open({
  message: 'Notification Title',
  description: 'This notification will close after 10 seconds.',
  duration: 10
});

Specifying the position of the notification

This feature allows setting the position of notifications globally. You can specify the placement (e.g., topRight, topLeft, bottomRight, bottomLeft) and the distance from the top or bottom of the viewport.

notification.config({
  placement: 'topRight',
  top: 50,
  bottom: 50
});

Other packages similar to rc-notification

Readme

Source

rc-notification

React Notification UI Component

NPM version dumi build status Test coverage Dependencies DevDependencies npm download bundle size

Install

rc-notification

Usage

import Notification from 'rc-notification';

Notification.newInstance({}, notification => {
  notification.notice({
    content: 'content'
  });
});

Compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versions

Example

http://localhost:8001

online example: https://notification-react-component.vercel.app

API

Notification.newInstance(props, (notification) => void) => void

props details:

nametypedefaultdescription
prefixClsStringprefix class name for notification container
styleObject{'top': 65, left: '50%'}additional style for notification container.
getContainergetContainer(): HTMLElementfunction returning html node which will act as notification container
maxCountnumbermax notices show, drop first notice if exceed limit

notification.notice(props)

props details:

nametypedefaultdescription
contentReact.Elementcontent of notice
keyStringid of this notice
closableBooleanwhether show close button
onCloseFunctioncalled when notice close
durationnumber1.5after duration of time, this notice will disappear.(seconds)
styleObject { right: '50%' } additional style for single notice node.
closeIconReactNodespecific the close icon.
propsObjectAn object that can contain data-*, aria-*, or role props, to be put on the notification div. This currently only allows data-testid instead of data-* in TypeScript. See https://github.com/microsoft/TypeScript/issues/28960.

notification.removeNotice(key:string)

remove single notice with specified key

notification.destroy()

destroy current notification

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rc-notification is released under the MIT license.

Keywords

FAQs

Last updated on 07 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc