{"id":3972,"url":"https://github.com/magicismight/react-native-root-toast","last_synced_at":"2025-05-12T15:32:59.023Z","repository":{"id":4239391,"uuid":"52331132","full_name":"magicismight/react-native-root-toast","owner":"magicismight","description":"react native toast like component, pure javascript solution","archived":false,"fork":false,"pushed_at":"2025-04-16T04:30:57.000Z","size":4589,"stargazers_count":2120,"open_issues_count":92,"forks_count":404,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-05-08T10:49:12.856Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"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/magicismight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2016-02-23T04:52:07.000Z","updated_at":"2025-05-01T00:30:09.000Z","dependencies_parsed_at":"2024-04-28T06:22:58.091Z","dependency_job_id":"345f34e9-2cce-4695-9eae-749fca822d27","html_url":"https://github.com/magicismight/react-native-root-toast","commit_stats":{"total_commits":71,"total_committers":24,"mean_commits":"2.9583333333333335","dds":0.5915492957746479,"last_synced_commit":"a21d38a5733649f340891b4816d4f00730306831"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicismight%2Freact-native-root-toast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicismight%2Freact-native-root-toast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicismight%2Freact-native-root-toast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicismight%2Freact-native-root-toast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicismight","download_url":"https://codeload.github.com/magicismight/react-native-root-toast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253336916,"owners_count":21892798,"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":[],"created_at":"2024-01-05T20:16:57.296Z","updated_at":"2025-05-12T15:32:58.996Z","avatar_url":"https://github.com/magicismight.png","language":"JavaScript","funding_links":[],"categories":["Components","JavaScript","Installation","Libraries","Others"],"sub_categories":["UI"],"readme":"## react-native-root-toast [![npm version](https://badge.fury.io/js/react-native-root-toast.svg)](http://badge.fury.io/js/react-native-root-toast)\n\n-----------------------\n\n#### Features\n1. Pure javascript solution.\n2. Support both Android and iOS.\n3. Lots of custom options for Toast.\n4. You can show/hide Toast by calling api or using Component inside render.\n\n![screen-shoots](./Example/screen-shoots.gif)\n\n### Install\n\n`npm install react-native-root-toast`\n\n\u003e react-native-root-toast \u003e= 2.1.0 only supports react-native \u003e= 0.47.0 , for lower version choose 2.0.0 or below.\n\nIn react native \u003e= 0.62, the new LogBox component would impact this component's initialization. To make it work we have to explicitly insert a mount point in your app like this:\n\n```js\n// in your entry file like `App.js`\n\n// In theory you don't have to install `react-native-root-siblings` because it's a dep of root-toast\n// But you can install it explicitly if your editor complains about it.\nimport { RootSiblingParent } from 'react-native-root-siblings';\n\n// in your render function \nreturn (\n  \u003cRootSiblingParent\u003e  // \u003c- use RootSiblingParent to wrap your root component\n    \u003cApp /\u003e\n  \u003c/RootSiblingParent\u003e\n);\n            \n```\n\nYou can skip this step if your react-native is lower than 0.62. And actually you can inject RootSiblingParent into anywhere like a react portal, for example if you have multiple rootviews you can choose where to display the root toast.\n\nRead more about [`react-native-root-siblings`](https://github.com/magicismight/react-native-root-siblings) which powers `react-native-root-toast`. \n\n\n### Usage\n\nThere are two different ways to manage a Toast.\n\n##### **Calling api**\n\n```js\nimport Toast from 'react-native-root-toast';\n\n\n// Add a Toast on screen.\nlet toast = Toast.show('This is a message', {\n    duration: Toast.durations.LONG,\n    position: Toast.positions.BOTTOM,\n    shadow: true,\n    animation: true,\n    hideOnPress: true,\n    delay: 0,\n    onShow: () =\u003e {\n        // calls on toast\\`s appear animation start\n    },\n    onShown: () =\u003e {\n        // calls on toast\\`s appear animation end.\n    },\n    onHide: () =\u003e {\n        // calls on toast\\`s hide animation start.\n    },\n    onHidden: () =\u003e {\n        // calls on toast\\`s hide animation end.\n    }\n});\n\n// You can manually hide the Toast, or it will automatically disappear after a `duration` ms timeout.\nsetTimeout(function () {\n    Toast.hide(toast);\n}, 500);\n\n```\n\n##### **Using a Component**\n\n**NOTE:**\nShowing a toast by using a Component inside render, The toast will be automatically disappeared when the `\u003cToast /\u003e` is unmounted.\n\n```js\nimport React, {Component} from 'react-native';\nimport Toast from 'react-native-root-toast';\n\nclass Example extends Component{\n    state = {\n        visible: false\n    }\n\n    componentDidMount() {\n        setTimeout(() =\u003e this.setState({\n            visible: true\n        }), 2000); // show toast after 2s\n\n        setTimeout(() =\u003e this.setState({\n            visible: false\n        }), 5000); // hide toast after 5s\n    };\n\n    render() {\n        return \u003cToast\n            visible={this.state.visible}\n            position={50}\n            shadow={false}\n            animation={false}\n            hideOnPress={true}\n        \u003eThis is a message\u003c/Toast\u003e;\n    }\n}\n\n```\n\n---\n\n## Reference\n\n### Props\n\nName                | Default                  |  Type    | Description\n--------------------|--------------------------|----------|---------------------------\nduration            | Toast.durations.SHORT    | Number   | The duration of the toast. (Only for api calling method)\nvisible             | false                    | Bool     | The visibility of toast. (Only for Toast Component)\nposition            | Toast.positions.BOTTOM   | Number   | The position of toast showing on screen (A negative number represents the distance from the bottom of screen. A positive number represents the distance form the top of screen. `0` will position the toast to the middle of screen.)\nanimation           | true                     | Bool     | Should preform an animation on toast appearing or disappearing.\nshadow              | true                     | Bool     | Should drop shadow around Toast element.\nbackgroundColor     | null                     | String   | The background color of the toast.\nshadowColor         | null                     | String   | The shadow color of the toast.\ntextColor           | null                     | String   | The text color of the toast.\ndelay               | 0                        | Number   | The delay duration before toast start appearing on screen.\nhideOnPress         | true                     | Bool     | Should hide toast that appears by pressing on the toast.\nopacity             | 0.8                      | Number   | The Toast opacity.\nonShow              | null                     | Function | Callback for toast\\`s appear animation start\nonShown             | null                     | Function | Callback for toast\\`s appear animation end\nonHide              | null                     | Function | Callback for toast\\`s hide animation start\nonHidden            | null                     | Function | Callback for toast\\`s hide animation end\n\n### Constants\n\n##### Toast.durations\n\npresets of duration of the toast.\n\n1. Toast.durations.SHORT (equals to *2000*)\n\n2. Toast.durations.LONG (equals to *3500*)\n\n##### Toast.positions\n\npresets of position of toast.\n\n1. Toast.positions.TOP (equals to *20*)\n\n2. Toast.positions.BOTTOM (equals to *-20*)\n\n3. Toast.positions.CENTER (equals to *0*)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicismight%2Freact-native-root-toast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicismight%2Freact-native-root-toast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicismight%2Freact-native-root-toast/lists"}