Simple React JS text banner component with fade in / out animation and customizable options.
It is a simple customizable text banner component (like warning, error, success). Styles (font and background) can be customized or you can use the built-in variants. By default the banner has a fade in and fade out animation of 1s (customizable). This can be used in two ways:
- Shown for a specific amount of time using
visibleTimeprop. - Handled manually with manual dismissal.
How to thank me? Just click on ⭐️ button or buy me a tea using the donation button below :)
Install it from npm and include it in your React build process (using Webpack, Browserify, etc).
npm i react-js-bannerImport Banner in your react component.
import Banner from 'react-js-banner';<Banner
id="banner1"
title="This is an example Banner Title"
css={{ color: "#000", backgroundColor: "grey", fontFamily: "arial" }}
/>You can now use variant prop for predefined styles: success, error, warning, info.
<Banner
title="Success!"
variant="success"
/>
<Banner
title="Error Occurred"
variant="error"
/>Fix the banner to the top or bottom of the screen using the position prop: top, bottom.
<Banner
title="Fixed Top Banner"
variant="info"
position="top"
/>Add a close button with the dismissible prop.
<Banner
title="Closable Banner"
variant="warning"
dismissible={true}
/>If you want the banner to be available for a specific amount of time, visibleTime prop can be passed:
<Banner
title="This banner disappears in 3 seconds"
visibleTime={3000}
/>Example of banner with image:
import logo from './logo.svg';<Banner
title="This is an example banner with Image"
image={logo}
imageClass="App-logo"
css={{ color: "white", backgroundColor: "#333" }}
/>The banner accepts a list of children to display complex content.
<Banner>
<div>
<h1>h1</h1>
<h2>h2</h2>
</div>
</Banner>| Name | Type | Mandatory | Description |
|---|---|---|---|
| id | String | N | Banner Id (optional unless using callback) |
| title | String | N | Adding some text will make the banner appear |
| css | object | N | CSS customizations |
| variant | String | N | Predefined style: 'success', 'error', 'warning', 'info' |
| position | String | N | fixed position: 'top', 'bottom' |
| dismissible | bool | N | shows a close button |
| visibleTime | number | N | Time in milliseconds you want the banner to be visible |
| image | String | N | image to appear at the left of text |
| imageClass | String | N | image css class e.g "image-customized-class" |
| transitionAppearTime | number | N | time for the banner to appear |
| transitionTime | number | N | time for the transition to take |
| onHideCallback | function | N | callback when the popup hides (to be used with visible time prop or dismissible) |
If you think that any information you obtained here is useful and worth of some money and are willing to pay for it, feel free to send any amount through Paypal :)
You can also follow me on Patreon: https://patreon.com/Jacware
- Major Update: Component refactored to Functional Component (Hooks).
- New Feature:
variantprop added (success, error, warning, info). - New Feature:
positionprop added (top, bottom). - New Feature:
dismissibleprop added. - Update: Dependencies updated to specific React 18/19 support and Webpack 5.
- Package size further optimized from ~118kb+ to <11kb packed / 31kb unpacked :)
- Package size optimized from ~600kb+ to <100kb
- New function callback when the popup hides.
- Enhanced fade in / out animations.
- Code optimizations.
- Bug Fixes
- Dependencies updated
- Added ability to accept children.
- Added ability to show / hide banner whenever is required via new showBanner prop
- Banner can render HTML snippets
- Visible time feature added
- Initial release
Licensed under the MIT License © jciccio

