fastnotify
v0.2.4
Published
A fast notification component. 11 kb ~
Maintainers
Readme
toast
The tiniest toast notification. 3.1kB - minified & gzipped
Preview:
Installation
Prerequisite: React
npm i fastnotify
Options
| Prop | Default | Type | Description |
| ---------------- | ------- | ---------- | ---------------------------------------- |
| isOpen | false | boolean | Triggers the notification to open. |
| hasCloseBtn | false | boolean | Adds/hides close button from toast. |
| hasAutoDismiss | true | boolean | Auto dismisses/keeps toast in view. |
| closeCallback | null | function | Triggers after toast closes. |
| duration | 2000 | number | Duration of toast before it's dismissed. |
| title | | string | Toast header. |
| description | | string | Toast description. |
| children | | node | Custom elements to add inside toast. |
| classNames | [] | array | Class names to add to the toast. |
Usage
import React, { useState } from 'react';
import Toast from 'fastnotify';
function App() {
const [isOpen, setToast] = useState(true);
return (
<div className="App">
<Toast
isOpen={isOpen}
hasAutoDismiss={false}
hasCloseBtn
closeCallback={() => setToast(false)}
description="There's some great info here."
title="App Notification!!"
duration={5000}
classNames={['info']} // 'success', 'info', 'warning', 'error'
/>
</div>
);
}
export default App;Optional custom elements:
<Toast
isOpen={isOpen}
closeCallback={() => setToast(false)}
hasCloseBtn
description="There's some great info here."
title="App Notification!!"
>
<h1>Add your own custom elements in here.</h1>
</Toast>