{"id":13436471,"url":"https://github.com/mathieudutour/react-progress-button","last_synced_at":"2025-05-16T08:03:01.931Z","repository":{"id":31161439,"uuid":"34721557","full_name":"mathieudutour/react-progress-button","owner":"mathieudutour","description":":cyclone: Simple react.js component for an inline progress indicator","archived":false,"fork":false,"pushed_at":"2022-02-15T18:00:33.000Z","size":349,"stargazers_count":527,"open_issues_count":8,"forks_count":65,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-16T08:01:44.756Z","etag":null,"topics":["button","component","progress","react"],"latest_commit_sha":null,"homepage":"https://mathieudutour.github.io/react-progress-button","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/mathieudutour.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}},"created_at":"2015-04-28T09:32:05.000Z","updated_at":"2025-03-24T17:53:55.000Z","dependencies_parsed_at":"2022-09-16T03:02:09.520Z","dependency_job_id":null,"html_url":"https://github.com/mathieudutour/react-progress-button","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieudutour%2Freact-progress-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieudutour%2Freact-progress-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieudutour%2Freact-progress-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieudutour%2Freact-progress-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathieudutour","download_url":"https://codeload.github.com/mathieudutour/react-progress-button/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493381,"owners_count":22080126,"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":["button","component","progress","react"],"created_at":"2024-07-31T03:00:48.816Z","updated_at":"2025-05-16T08:03:01.908Z","avatar_url":"https://github.com/mathieudutour.png","language":"JavaScript","readme":"# react-progress-button\n\n[![build status](https://img.shields.io/travis/mathieudutour/react-progress-button/master.svg?style=flat-square)](https://travis-ci.org/mathieudutour/react-progress-button)\n[![npm version](https://img.shields.io/npm/v/react-progress-button.svg?style=flat-square)](https://www.npmjs.com/package/react-progress-button)\n[![Dependency Status](https://david-dm.org/mathieudutour/react-progress-button.svg)](https://david-dm.org/mathieudutour/react-progress-button)\n[![devDependency Status](https://david-dm.org/mathieudutour/react-progress-button/dev-status.svg)](https://david-dm.org/mathieudutour/react-progress-button#info=devDependencies)\n\n\u003e Simple [React](http://facebook.github.io/react/index.html) component for a circular Progress Button.\n\n### [Demo](https://mathieudutour.github.io/react-progress-button)\n\n[![Demo](https://cdn.rawgit.com/mathieudutour/react-progress-button/master/example/demo.gif \"Demo\")](https://github.com/mathieudutour/react-progress-button/blob/master/example/index.html)\n\n## Install\n\n```bash\nnpm install react-progress-button --save\n```\n\n## Example\n\n### Controlled usage:\n\n```javascript\nimport ProgressButton from 'react-progress-button'\n\nconst App = React.createClass({\n  getInitialState () {\n    return {\n      buttonState: ''\n    }\n  },\n\n  render () {\n    return (\n      \u003cdiv\u003e\n        \u003cProgressButton onClick={this.handleClick} state={this.state.buttonState}\u003e\n          Go!\n        \u003c/ProgressButton\u003e\n      \u003c/div\u003e\n    )\n  },\n\n  handleClick () {\n    this.setState({buttonState: 'loading'})\n    // make asynchronous call\n    setTimeout(() =\u003e {\n      this.setState({buttonState: 'success'})\n    }, 3000)\n  }\n})\n```\n\n[Source](https://github.com/mathieudutour/react-progress-button/blob/master/example/index.html)\n\n### Using Promises:\n\nIf the function passed in via the `onClick` prop return a Promise or if a promise\nis passed as an argument of the `loading` method,\nthe component will automatically transition to its success or error\nstates based on the outcome of the Promise without the need for\nexternal manipulation of state using a ref.\n\n```javascript\nimport ProgressButton from 'react-progress-button'\n\nconst App = React.createClass({\n  render () {\n    return (\n      \u003cdiv\u003e\n        \u003cProgressButton onClick={this.handleClick}\u003e\n          Go!\n        \u003c/ProgressButton\u003e\n      \u003c/div\u003e\n    )\n  },\n\n  handleClick() {\n    return new Promise(function(resolve, reject) {\n      setTimeout(resolve, 3000)\n    })\n  }\n});\n```\n\n[Source](https://github.com/mathieudutour/react-progress-button/blob/master/example/index-promises.html)\n\n## API\n\n### Props\n\nAll props are optional. All props other than that will be passed to the top element.\n\n##### controlled\n\n`true` if you control the button state (by providing `props.state` and `props.onClick`).`false` to let the button manage its state with Promises.  \n\n##### classNamespace\n\nNamespace for CSS classes, default is `pb-` i.e CSS classes are `pb-button`.\n\n##### durationError\n\nDuration (ms) before going back to normal state when an error occurs,\ndefault is 1200\n\n##### durationSuccess\n\nDuration (ms) before going back to normal state when an success occurs,\ndefault is 500\n\n##### onClick\n\nFunction to call when the button is clicked; if it returns a Promise\nthen the component will transition to the success/error state based on\nthe outcome of the Promise\n\n##### onError\n\nFunction to call when going back to the normal state after an error\n\n##### onSuccess\n\nFunction to call when going back to the normal state after a success\n\n##### state\n\nState of the button if you do not want to use the functions. Can be `''`, `loading`, `success`, `error` or `disabled`.\n\n##### type\n\nType of the button (can be 'submit' for example).\n\n##### form\n\nId of the form to submit (useful if the button is not directly inside the form).\n\n##### shouldAllowClickOnLoading\n\nWhether click event should bubble when in loading state\n\n### Methods\n\n##### loading()\n\nPut the button in the loading state.\n\n##### disable()\n\nPut the button in the disabled state.\n\n##### notLoading(), enable()\n\nPut the button in the normal state.\n\n##### success([callback, dontGoBackToNormal])\n\nPut the button in the success state. Call the callback or the onSuccess prop when going back to the normal state.\n\n##### error([callback])\n\nPut the button in the error state. Call the callback or the onError prop when going back to the normal state.\n\n## Styles\n\nLook at [react-progress-button.css](https://github.com/mathieudutour/react-progress-button/blob/master/react-progress-button.css) for an idea on how to style this component.\n\nIf you are using webpack, you'll need to have ```css-loader``` installed and include \n```\n {\n   test: /\\.css$/,\n   loader: \"style!css\"\n }\n ```\n \n in your webpack config. In your jsx file you can then import the CSS with ```import \"../node_modules/react-progress-button/react-progress-button.css\";``` although the path depends on how deeply nested your jsx is. If you wish to theme it yourself, copy the CSS to a convenient location and point the import path at the copy, which is part of your repo, unlike the original in ```node_modules```. \n\n## License\n\n  MIT\n","funding_links":[],"categories":["Uncategorized","UI Components","Demos","\u003csummary\u003eUI Components\u003c/summary\u003e"],"sub_categories":["Uncategorized","Loader"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieudutour%2Freact-progress-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathieudutour%2Freact-progress-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieudutour%2Freact-progress-button/lists"}