Description
This library implements a component which lived in my head rent-free for a very long time, but I couldn’t find React implementation of it at all, not even a single one. And that’s why I decided to implement it myself. It’s called react-local-toast and provides a toast component, which is linked to a particular component on a page, which enables developers to provide located feedback (instead of page-wise feedback which you can provide with normal toast)
react-local-toast alternatives and similar libraries
Based on the "UI Components" category.
Alternatively, view react-local-toast alternatives based on common mentions on social networks and blogs.
-
Swiper
Most modern mobile touch slider with hardware accelerated transitions -
slate
A completely customizable framework for building rich text editors. (Currently in beta.) -
sortablejs
Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required. -
react-beautiful-dnd
Beautiful and accessible drag and drop for lists with React -
react-virtualized
React components for efficiently rendering large lists and tabular data -
react-table
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table -
tiptap
The headless rich text editor framework for web artisans. -
sweetalert2
✨ A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. 🇺🇦 -
TinyMCE
The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular -
react-window
React components for efficiently rendering large lists and tabular data -
react-map-gl
React friendly API wrapper around MapboxGL JS -
react-dates
An easily internationalizable, mobile-friendly datepicker library for the web -
AG Grid
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript. -
downshift 🏎
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components. -
react-content-loader
⚪ SVG-Powered component to easily create skeleton loadings. -
react-color
:art: Color Pickers from Sketch, Photoshop, Chrome, Github, Twitter & more -
react-sortable-hoc
A set of higher-order components to turn any list into an animated, accessible and touch-friendly sortable list✌️ -
react-data-grid
Feature-rich and customizable data grid React component -
react-big-calendar
gcal/outlook like calendar component -
react-datepicker
A simple and reusable datepicker component for React -
react-dropzone
Simple HTML5 drag-drop zone with React.js. -
victory
A collection of composable React components for building interactive data visualizations -
react-player
A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion -
react-chartjs-2
React components for Chart.js, the most popular charting library -
react-text-mask
Input mask for React, Angular, Ember, Vue, & plain JavaScript -
react-pdf
Display PDFs in your React app as easily as if they were images. -
react-draft-wysiwyg
A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg -
lightGallery
A customizable, modular, responsive, lightbox gallery plugin. -
google-map-react
Google map library for react that allows rendering components as markers :tada: -
react-day-picker
DayPicker is a customizable date picker component for React. Add date pickers, calendars, and date inputs to your web applications. -
react-lazyload
Lazy load your component, image or anything matters the performance. -
react-autosuggest
WAI-ARIA compliant React autosuggest component -
fixed-data-table
A React table component designed to allow presenting thousands of rows of data.
SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of react-local-toast or a related project?
README
react-local-toast
Local toast helps you to provide feedback related to particular components on page
Features
- Local toasts are linked to particular component in DOM.
- Toast can be displayed on right/left/top/bottom side of component.
- Toast can be hidden after some timout or hidden programatically.
- Component might have multiple toasts.
- Multiple toasts stucks vertically (even if displayed on left or right side).
info
,success
,warning
,error
andloading
toasts out of the box.- You can bring your own design. Or your own Toast component. Or your custom implementation of toasts.
- WAI-ARIA support.
- TypeScript!
Documentation and showcase
Can be found here. Check it out, I spent a lot of effort making it 😅.
Installation
npm install react-local-toast --save
# Or if you prefer yarn
yarn add react-local-toast
Basic Usage
react-local-toast doesn't automatically inject its styles into DOM, you need to do that. In most cases it will be just:
import 'react-local-toast/dist/bundle.css';
// There is minified version too!
import 'react-local-toast/dist/bundle.min.css';
This should work fine for most of tools (Create React App included). For more specific use cases (e.g. using toasts in Shadow DOM) you might want to inject styles manually.
Now you need to wrap your application in LocalToastProvider
.
import React from 'react';
import { LocalToastProvider } from 'react-local-toast';
export default () => {
return (<LocalToastProvider>
{/* All your components that will use local toasts should be children of this provider. */}
<App />
</LocalToastProvider>);
};
Local toasts are linked to particular components on page, so let's mark our component as target for local toast:
import React from 'react';
import { LocalToastTarget } from 'react-local-toast';
export const App = () => {
return (<div>
<p>This component should be inside LocalToastProvider</p>
{/* Wrap your component with <LocalToastTarget> */}
<LocalToastTarget name="btn">
<button>Click me please!</button>
</LocalToastTarget>
</div>);
};
Local toast uses refs to get position of component, so in case you want to use toasts with functional components – make sure they are wrapped in React.forwardRef
.
And final piece! Update your component to actually produce local toasts:
import React from 'react';
// New import here !!
import { LocalToastTarget, useLocalToast } from 'react-local-toast';
export const App = () => {
// Use hook to show and hide toasts
const {showToast, removeToast} = useLocalToast();
return (<div>
<p>This component should be inside LocalToastProvider</p>
<LocalToastTarget name="btn">
<button onClick={() => showToast('btn', 'Hello my first toast!')}>Click me please!</button>
</LocalToastTarget>
</div>);
};
In case you need to show toast from class component, you can use HOC like this:
import { LocalToastTarget, withLocalToast, LocalToastHocProps } from 'react-local-toast';
interface Props extends LocalToastHocProps {
name: string
}
class ClassComp extends React.Component<Props, any> {
sayHello = () => {
this.props.showToast('class_comp', `Hello, ${this.props.name}!`)
};
render() {
return (<div>
<LocalToastTarget name='class_comp'>
<button onClick={sayHello}>Say hello</button>
</LocalToastTarget>
</div>);
}
}
// And later use thic component as you usually do
export default withLocalToast(ClassComp);
This will pass toast-related functions (exactly same as in useLocalToast
hook) as props to wrapped component.
Cool, huh?
License
MIT
*Note that all licence references and agreements mentioned in the react-local-toast README section above
are relevant to that project's source code only.