Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/javadbat/jb-switch-react
react switch btn
https://github.com/javadbat/jb-switch-react
Last synced: 7 days ago
JSON representation
react switch btn
- Host: GitHub
- URL: https://github.com/javadbat/jb-switch-react
- Owner: javadbat
- License: mit
- Created: 2019-05-08T13:18:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-23T14:15:01.000Z (29 days ago)
- Last Synced: 2024-11-23T15:23:23.989Z (29 days ago)
- Language: TypeScript
- Size: 160 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# jb-switch-react
simple switch component for react with loading ability
sample:## installation
run `npm install jb-switch-react` to install package with npm
## usage
import component in your page `import {JBSwitch} from 'jb-switch-react'`
use below syntax in your render function
```jsx
onChange(e)} >
```as you can see in above example `value` is on-way binding like normal react forms input trueTitle is a title that place on true side of component and get bold on `value == true` onChange is standard too
if you want to show loading in switch just make `isLoading = true````javascript
onChange(e){
setIsLoading(true)
return new Promise((resolve,reject)=>{
fetch(request).then((response)=>return response.json).then((data)=>{
setIsLoading(false)
resolve();
})
})
}
```demo image:
![](demo-gif.gif)