
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
react-customized-notifications
Advanced tools
A React Notification System forked from https://github.com/igorprado/react-notification-system
/!\ forked from https://github.com/igorprado/react-notification-system /!\
This component is available as CommonJS and UMD module. Install via NPM running:
npm install react-customized-notifications
addNotification(notification)Add a notification object. This displays the notification based on the object you passed.
Returns the notification object to be used to programmatically dismiss a notification.
removeNotification(notification)Remove a notification programmatically. You can pass an object returned by addNotification() or by onAdd() callback. If passing an object, you need to make sure it must contain the uid property. You can pass only the uid too: removeNotification(uid).
editNotification(notification)Edit a notification programmatically. You can pass an object previously returned by addNotification() or by onAdd() callback. If passing an object, you need to make sure it must contain the uid property. You can pass only the uid too: editNotification(uid).
clearNotifications()Removes ALL notifications programatically.
The notification object has the following properties:
| Name | Type | Default | Description |
|---|---|---|---|
| title | string | null | Title of the notification |
| message | string | null | Message of the notification |
| level | string | null | Level of the notification. Available: success, error, warning and info |
| position | string | tr | Position of the notification. Available: tr (top right), tl (top left), tc (top center), br (bottom right), bl (bottom left), bc (bottom center) |
| autoDismiss | integer | 5 | Delay in seconds for the notification go away. Set this to 0 to not auto-dismiss the notification |
| dismissible | bool | true | Set if notification is dismissible by the user. See more |
| action | object | null | Add a button with label and callback function (callback is optional). See more |
| children | element,string | null | Adds custom content, and overrides action (if defined) See more |
| onAdd | function | null | A callback function that will be called when the notification is successfully added. The first argument is the original notification e.g. function (notification) { console.log(notification.title + 'was added'); } |
| onRemove | function | null | A callback function that will be called when the notification is about to be removed. The first argument is the original notification e.g. function (notification) { console.log(notification.title + 'was removed'); } |
| uid | integer/string | null | Overrides the internal uid. Useful if you are managing your notifications id. Notifications with same uid won't be displayed. |
If set to false, the notification will not display the dismiss ('x') button and will only be dismissible programmatically or after autoDismiss timeout. See more
Add a button and a callback function to the notification. If this button is clicked, the callback function is called (if provided) and the notification is dismissed.
notification = {
[...],
action: {
label: 'Button name',
callback: function() {
console.log('Notification button clicked!');
}
}
}
Add custom content / react elements
notification = {
[...],
children: (
<div>
<h2>Hello World</h2>
<a>Anchor</a>
</div>
)
}
This component was made to work as plug and play. For that, a handcrafted style was added to it and is used as inline CSS.
You can change this style by overriding the default inline styles or disable all inline styles and use your own styles.
For this, use the style prop to pass an object with your styles. Your object must be something like this:
var style = {
NotificationItem: { // Override the notification item
DefaultStyle: { // Applied to every notification, regardless of the notification level
margin: '10px 5px 2px 1px'
},
success: { // Applied only to the success notification item
color: 'red'
}
}
}
<NotificationSystem ref="notificationSystem" style={style} />
Refer to this file to see what can you override.
To disable all inline styles, just pass false to the prop style.
<NotificationSystem ref="notificationSystem" style={false} />
Here is the notification HTML:
<div class="notifications-wrapper">
<div class="notifications-{position}"> <!-- '{position}' can be one of the positions available: ex: notifications-tr -->
<div class="notification notification-{level} notification-{state} {notification-not-dismissible}"> <!-- '{level}' can be: success | error | warning | info. '{state}' can be: visible | hidden. {notification-not-dismissible} is present if notification is not dismissible by user -->
<h4 class="notification-title">Default title</h4>
<div class="notification-message">Default message</div>
<span class="notification-dismiss">Ă—</span>
<div class="notification-action-wrapper">
<button class="notification-action-button">Action button</button>
</div>
</div>
</div>
</div>
Using this method you have to take care of every style, from containers positions to animations. To control animations, use the classes notification-visible and notification-hidden. If your CSS styles will not handle any animation (transition), you need to set the prop noAnimation to true when adding the Notification System component:
<NotificationSystem ref="notificationSystem" noAnimation={true} />
See #74 for more details.
Clone this repo by running:
git clone git@github.com:MomchilGorchev/react-notification-system.git
Enter the project folder and install the dependencies:
npm install
To start a development server and use the example app to load the component, type:
npm start
Open http://localhost:8000.
Run the tests:
npm test
You can find the coverage details under coverage/ folder.
After that, just edit the files under src/ and example/src/app.js. It uses React hot reload.
This component is under construction. I will add more guidelines to who wants to contribute.
FAQs
A React Notification System forked from https://github.com/igorprado/react-notification-system
We found that react-customized-notifications demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.