Gathering detailed insights and metrics for react-switch-selector
Gathering detailed insights and metrics for react-switch-selector
Gathering detailed insights and metrics for react-switch-selector
Gathering detailed insights and metrics for react-switch-selector
npm install react-switch-selector
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
11 Stars
293 Commits
4 Forks
1 Watching
19 Branches
2 Contributors
Updated on 06 Aug 2024
TypeScript (92.82%)
JavaScript (4.03%)
HTML (3.14%)
Cumulative downloads
Total Downloads
Last day
15.7%
980
Compared to previous day
Last week
5%
5,266
Compared to previous week
Last month
-5%
21,649
Compared to previous month
Last year
22.2%
257,098
Compared to previous year
1
25
https://gr34se.github.io/react-switch-selector/
1npm install react-switch-selector --save
or
1yarn add react-switch-selector
SwitchSelector will stretch to fill its parent size (both width and height), so it's required create dedicated div container.
1import SwitchSelector from "react-switch-selector";
1const options = [ 2 { 3 label: <span>Foo</span>, 4 value: { 5 foo: true 6 }, 7 selectedBackgroundColor: "#0097e6", 8 }, 9 { 10 label: "Bar", 11 value: "bar", 12 selectedBackgroundColor: "#fbc531" 13 } 14]; 15 16const onChange = (newValue) => { 17 console.log(newValue); 18}; 19 20const initialSelectedIndex = options.findIndex(({value}) => value === "bar"); 21 22return ( 23 <div className="your-required-wrapper" style={{width: 100, height: 30}}> 24 <SwitchSelector 25 onChange={onChange} 26 options={options} 27 initialSelectedIndex={initialSelectedIndex} 28 backgroundColor={"#353b48"} 29 fontColor={"#f5f6fa"} 30 /> 31 </div> 32);
Prop name | Type | Default | Required | Note |
---|---|---|---|---|
options | Array of OptionType | [] | true | Options array to render. Each item has a label, value and optional styling props |
onChange | Function | (v) => (console.log(v)) | true | onChange callback that returns selected Option's value |
name | string | undefined | false | HTML input name. Needed if you want to have multiple instances of the component |
initialSelectedIndex | number | 0 | false | Initially selected index of options array |
forcedSelectedIndex | number | undefined | false | Force selectedIndex with this prop (can be also used to resetting the toggle) |
border | string/number | 0 | false | Border of wrapping div |
backgroundColor | string | #ecf0f1 | false | Background color of wrapping div |
selectedBackgroundColor | string | #2ecc71 | false | Background of selected Option |
wrapperBorderRadius | number/CSS.Property.BorderRadius | 20 | false | Border radius of wrapping div |
optionBorderRadius | number/CSS.Property.BorderRadius | 18 | false | Border radius of Option component |
fontSize | number | 14 | false | Font size of Option's label |
fontColor | string | #000 | false | Font color of Option's label |
selectedFontColor | string | #fff | false | Font color of selected Option's label |
selectionIndicatorMargin | number | 2 | false | Inner px margin of selected option indicator |
disabled | boolean | false | false | Disabling the toggle |
Property name | Type | Default | Required | Note |
---|---|---|---|---|
label | string/number/ReactElement/HTMLElement | undefined | true | Option's label |
value | any | undefined | true | Option's value that is returned by onChange callback |
selectedBackgroundColor | string | undefined | false | Background of this selected Option |
fontColor | string | undefined | false | Font color of this Option's label |
selectedFontColor | string | undefined | false | Font color of this selected Option's label |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
21 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More