All Projects → blvdmitry → react-awesome-toasts

blvdmitry / react-awesome-toasts

Licence: MIT license
Toast notifications for react.

Programming Languages

typescript
32286 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to react-awesome-toasts

a11ycolor
🌈 Generate the nearest accessible color
Stars: ✭ 29 (-54.69%)
Mutual labels:  accessibility, a11y
dorai-ui
Accessible, unstyled, open-sourced, and fully functional react component library for building design systems
Stars: ✭ 34 (-46.87%)
Mutual labels:  accessibility, a11y
chusho
A library of bare & accessible components and tools for Vue.js 3
Stars: ✭ 47 (-26.56%)
Mutual labels:  accessibility, a11y
accessibility-ruleset-runner
eBay Accessibility Ruleset Runner automates 20% of WCAG 2.0 AA recommendations, saving time on manual testing.
Stars: ✭ 24 (-62.5%)
Mutual labels:  accessibility, a11y
buttonbuddy
Learn about accessible button contrast then generate your own accessible button color palette
Stars: ✭ 60 (-6.25%)
Mutual labels:  accessibility, a11y
makeup-js
Mono-repo for all vanilla JavaScript utility modules and headless ui
Stars: ✭ 28 (-56.25%)
Mutual labels:  accessibility, a11y
bones
Accessible HTML code patterns for common UI widgets such as tabs, menus, dialogs, etc.
Stars: ✭ 79 (+23.44%)
Mutual labels:  accessibility, a11y
Tanaguru
Automated accessibility (a11y) testing tool, with emphasis on reliablity and automation
Stars: ✭ 116 (+81.25%)
Mutual labels:  accessibility, a11y
AStack
The Missing SwiftUI Adaptive and Accessible Stacks Library.
Stars: ✭ 110 (+71.88%)
Mutual labels:  accessibility, a11y
togglific
Do you find web animations distracting? Togglific provides a distraction-free web experience!
Stars: ✭ 17 (-73.44%)
Mutual labels:  accessibility, a11y
a11y-checker
Identifies accessibility issues in HTML markup.
Stars: ✭ 103 (+60.94%)
Mutual labels:  accessibility, a11y
cluse
Sketch Plugin to check and adjust color contrast accessibility with live preview and sliders. Endorsed by Sketch.
Stars: ✭ 54 (-15.62%)
Mutual labels:  accessibility, a11y
accessibility-resources
Screen reader and WCAG testing resources to maintain a consistent approach to testing and documenting behaviour.
Stars: ✭ 25 (-60.94%)
Mutual labels:  accessibility, a11y
openacr
OpenACR is a digital native Accessibility Conformance Report (ACR). The initial development is based on Section 508 requirements. The main goal is to be able to compare the accessibility claims of digital products and services. A structured, self-validated, machine-readable documentation will provide for this.
Stars: ✭ 61 (-4.69%)
Mutual labels:  accessibility, a11y
accessible-name-automation-proof-of-concept
This is an experiment based on Accessibility Object Model (AOM). It tries to demonstrate that it is theoretically possible (in a certain way) to predict what the screen reader will say by focusing on semantic and non semantic elements with a bit of automated testing, thus reducing the need for manual testing.
Stars: ✭ 15 (-76.56%)
Mutual labels:  accessibility, a11y
a11y-contracting
Building Accessibility Best Practices into Contracting
Stars: ✭ 43 (-32.81%)
Mutual labels:  accessibility, a11y
cauldron
cauldron.dequelabs.com/
Stars: ✭ 50 (-21.87%)
Mutual labels:  accessibility, a11y
jquery-accessible-simple-tooltip-aria
jQuery accessible simple tooltip window, using ARIA
Stars: ✭ 22 (-65.62%)
Mutual labels:  accessibility, a11y
lint-html-with-css
Lint HTML with CSS. A collection of CSS snippets from the hashtag #lintHTMLwithCSS on twitter. These CSS snippets intend to warn developers about common mistakes made in HTML.
Stars: ✭ 35 (-45.31%)
Mutual labels:  accessibility, a11y
aria-at
Assistive Technology ARIA Experience Assessment
Stars: ✭ 115 (+79.69%)
Mutual labels:  accessibility, a11y

React Awesome Toasts

Easily customizable React notification system that manages its queue for you.

https://bananabobby.github.io/react-awesome-toasts/

  • 🎙 Screen reader accessibility
  • 🔧 Server side rendering support
  • 📱 Responsive
  • 📘 Typescript support
  • 📦 React is the only dependency
  • 🎉 5kb gzipped

Get started

Install the package:

yarn add react-awesome-toasts
// or
npm install react-awesome-toasts 

Wrap your app with ToastProvider:

import { ToastProvider } from 'react-awesome-toasts';

const App = () => {
    return (
        <ToastProvider>
            App content
        </ToastProvider>
    )
} 

Add toast methods to your component with one of the following methods:

With High Order Component:

import { withToast } from 'react-awesome-toasts';

const ToastButton = ({ toast }) => {
    const toastProps = {
        text: 'Message sent',
        actionText: 'Undo',
        ariaLabel: 'Message sent, click to undo',
        onActionClick: toast.hide,
    };
    
    return <Button onClick={() => toast.show(toastProps)}>Show toast</Button>;
}

export default withToast(ToastButton);

With ToastConsumer:

import { ToastConsumer } from 'react-awesome-toasts';

const toastProps = {
    text: 'Message sent',
    actionText: 'Undo',
    ariaLabel: 'Message sent, click to undo',
};

<ToastConsumer>
    {
        ({ show, hide }) => (
            <Button onClick={() => show({ ...toastProps, onActionClick: hide )}>
                Show toast
            </Button>    
        )
    }
</ToastConsumer>    

Provided methods

hide() - hides currently active toast.

show(props) - shows a toast and passes all props to the presentational component

Presentational Toast component

By default ToastProvider uses Toast component provided by the library. Toast component is responsible for the accessibility and responsiveness of notifications. Keep in mind, that if your replace it with your custom component - you will have to handle both of these features in your component if you need them in your app.

Default Toast component has follow properties:

Property Description
text string, required Message to display in notification
actionText string Text of the action button
onActionClick func Action button click handler
ariaLabel string Default: text property value. Should be used for better accessibility.
variant "error" Variant of message

Accessibility

Default presentational Toast component provides accessibility features:

  • When toast is opened, action button gets focused if its present
  • When toast is hidden, previous focus is restored
  • When toast is shown, screen reader reads its message or ariaLabel value. Since action button gets focused automatically - it's nice to have an aria-label that mentions it, e.g. `Item deleted, click to undo.

Customization

ToastProvider accepts properties for customizing the behaviour of the notifications.

Property Description
timeout number Default: 4500. The time until a toast is dismissed, in milliseconds.
component Presentational component for displaying notifications.
position top-right, bottom-right, top-left, bottom-left, top-center, bottom-center Default: bottom-left. Position of the toasts on the screen.

Roadmap

  • Improve accessibility for focused toast actions
  • Check colors AA accessibility level
  • Let toasts hide without animation
  • Custom container classnames
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].