{"id":20871408,"url":"https://jossmac.github.io/react-toast-notifications/","last_synced_at":"2025-05-12T12:34:20.520Z","repository":{"id":39495038,"uuid":"135772218","full_name":"jossmac/react-toast-notifications","owner":"jossmac","description":"🍞 A toast notification system for react","archived":false,"fork":false,"pushed_at":"2023-12-04T17:57:59.000Z","size":1291,"stargazers_count":2172,"open_issues_count":30,"forks_count":175,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-29T15:10:44.903Z","etag":null,"topics":["notifications","react","snackbar","toast","toast-notifications"],"latest_commit_sha":null,"homepage":"https://jossmac.github.io/react-toast-notifications","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jossmac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-01T23:34:45.000Z","updated_at":"2024-10-15T17:22:13.000Z","dependencies_parsed_at":"2024-06-01T12:11:04.481Z","dependency_job_id":"6e31e3ac-74c7-4c38-8929-941b6894490b","html_url":"https://github.com/jossmac/react-toast-notifications","commit_stats":{"total_commits":90,"total_committers":23,"mean_commits":"3.9130434782608696","dds":0.5333333333333333,"last_synced_commit":"2089a9e3511709e5194f1dd77a04d71eadbcb0b1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jossmac%2Freact-toast-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jossmac%2Freact-toast-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jossmac%2Freact-toast-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jossmac%2Freact-toast-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jossmac","download_url":"https://codeload.github.com/jossmac/react-toast-notifications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224993070,"owners_count":17403939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notifications","react","snackbar","toast","toast-notifications"],"created_at":"2024-11-18T06:18:21.388Z","updated_at":"2024-11-18T06:20:41.303Z","avatar_url":"https://github.com/jossmac.png","language":"JavaScript","funding_links":[],"categories":["🧰 React Toolkit"],"sub_categories":["Notifications"],"readme":"# 🚨 Not Maintained\n\nThis was a great project to learn from and fulfilled the requirements it set out to. Unfortunately, I can no-longer give this project the time it needs. Consider [react-hot-toast](https://github.com/timolins/react-hot-toast) as an alternative, or look at the source and make your own 🎉 (there really isn't much to it).\n\n[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n---\n\n\u003cimg align=\"right\" src=\"https://user-images.githubusercontent.com/2730833/41197727-5e0b4d2e-6cab-11e8-9d0d-873d1f8ebced.png\" alt=\"react-toast-notifications\" /\u003e\n\n# React Toast Notifications\n\nA configurable, composable, toast notification system for react.\n\nhttps://jossmac.github.io/react-toast-notifications\n\n### Install\n\n```bash\nyarn add react-toast-notifications\n```\n\n### Use\n\nWrap your app in the `ToastProvider`, which provides context for the `Toast` descendants.\n\n```jsx\nimport { ToastProvider, useToasts } from 'react-toast-notifications';\n\nconst FormWithToasts = () =\u003e {\n  const { addToast } = useToasts();\n\n  const onSubmit = async value =\u003e {\n    const { error } = await dataPersistenceLayer(value);\n\n    if (error) {\n      addToast(error.message, { appearance: 'error' });\n    } else {\n      addToast('Saved Successfully', { appearance: 'success' });\n    }\n  };\n\n  return \u003cform onSubmit={onSubmit}\u003e...\u003c/form\u003e;\n};\n\nconst App = () =\u003e (\n  \u003cToastProvider\u003e\n    \u003cFormWithToasts /\u003e\n  \u003c/ToastProvider\u003e\n);\n```\n\n## ToastProvider Props\n\nFor brevity:\n\n- `PlacementType` is equal to `'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right'`.\n- `TransitionState` is equal to `'entering' | 'entered' | 'exiting' | 'exited'`.\n\n| Property                               | Description                                                                                |\n| -------------------------------------- | ------------------------------------------------------------------------------------------ |\n| autoDismissTimeout `number`            | Default `5000`. The time until a toast will be dismissed automatically, in milliseconds.   |\n| autoDismiss `boolean`                  | Default: `false`. Whether or not to dismiss the toast automatically after a timeout.       |\n| children `Node`                        | Required. Your app content.                                                                |\n| components `{ ToastContainer, Toast }` | Replace the underlying components.                                                         |\n| newestOnTop `boolean`                  | Default `false`. When true, insert new toasts at the top of the stack.  |\n| placement `PlacementType`              | Default `top-right`. Where, in relation to the viewport, to place the toasts.              |\n| portalTargetSelector `string`          | Which element to attach the container's portal to. Uses `document.body` when not provided. |\n| transitionDuration `number`            | Default `220`. The duration of the CSS transition on the `Toast` component.                |\n\n## Toast Props\n\n| Property                           | Description                                                              |\n| ---------------------------------- | ------------------------------------------------------------------------ |\n| appearance                         | Used by the default toast. One of `success`, `error`, `warning`, `info`. |\n| children                           | Required. The content of the toast notification.                         |\n| autoDismiss `boolean`              | Inherited from `ToastProvider` if not provided.                          |\n| autoDismissTimeout `number`        | Inherited from `ToastProvider`.                                          |\n| onDismiss: `Id =\u003e void`            | Passed in dynamically. Can be called in a custom toast to dismiss it.    |\n| placement `PlacementType`          | Inherited from `ToastProvider`.                                          |\n| transitionDuration `number`        | Inherited from `ToastProvider`.                                          |\n| transitionState: `TransitionState` | Passed in dynamically.                                                   |\n\n## Hook\n\nThe `useToast` hook has the following signature:\n\n```jsx\nconst {\n  addToast,\n  removeToast,\n  removeAllToasts,\n  updateToast,\n  toastStack,\n} = useToasts();\n```\n\nThe `addToast` method has three arguments:\n\n1.  The first is the content of the toast, which can be any renderable `Node`.\n1.  The second is the `Options` object, which can take any shape you like. `Options.appearance` is required when using the `DefaultToast`. When departing from the default shape, you must provide an alternative, compliant `Toast` component.\n1.  The third is an optional callback, which is passed the added toast `ID`.\n\nThe `removeToast` method has two arguments:\n\n1.  The first is the `ID` of the toast to remove.\n1.  The second is an optional callback.\n\nThe `removeAllToasts` method has no arguments.\n\nThe `updateToast` method has three arguments:\n\n1.  The first is the `ID` of the toast to update.\n1.  The second is the `Options` object, which differs slightly from the add method because it accepts a `content` property.\n1.  The third is an optional callback, which is passed the updated toast `ID`.\n\nThe `toastStack` is an array of objects representing the current toasts, e.g.\n\n```jsx\n[\n  {\n    content: 'Something went wrong',\n    id: 'generated-string',\n    appearance: 'error',\n  },\n  { content: 'Item saved', id: 'generated-string', appearance: 'success' },\n];\n```\n\n## Replaceable Components\n\nTo bring each toast notification inline with your app, you can provide alternative components to the `ToastProvider`:\n\n```jsx\nimport { ToastProvider } from 'react-toast-notifications';\n\nconst MyCustomToast = ({ appearance, children }) =\u003e (\n  \u003cdiv style={{ background: appearance === 'error' ? 'red' : 'green' }}\u003e\n    {children}\n  \u003c/div\u003e\n);\n\nconst App = () =\u003e (\n  \u003cToastProvider components={{ Toast: MyCustomToast }}\u003e...\u003c/ToastProvider\u003e\n);\n```\n\nTo customize the existing component instead of creating a new one, you may import `DefaultToast`:\n\n```jsx\nimport { DefaultToast } from 'react-toast-notifications';\nexport const MyCustomToast = ({ children, ...props }) =\u003e (\n  \u003cDefaultToast {...props}\u003e\n    \u003cSomethingSpecial\u003e{children}\u003c/SomethingSpecial\u003e\n  \u003c/DefaultToast\u003e\n);\n```\n\n## Alternatives\n\nThis library may not meet your needs. Here are some alternative I came across whilst searching for this solution:\n\n- https://github.com/fkhadra/react-toastify\n- https://github.com/tomchentw/react-toastr\n- https://github.com/jesusoterogomez/react-notify-toast\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/jossmac.github.io%2Freact-toast-notifications%2F","html_url":"https://awesome.ecosyste.ms/projects/jossmac.github.io%2Freact-toast-notifications%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/jossmac.github.io%2Freact-toast-notifications%2F/lists"}