Gathering detailed insights and metrics for react-dropdown
Gathering detailed insights and metrics for react-dropdown
Gathering detailed insights and metrics for react-dropdown
Gathering detailed insights and metrics for react-dropdown
🔽 A dead simple dropdown component for React
npm install react-dropdown
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
670 Stars
176 Commits
251 Forks
5 Watching
24 Branches
42 Contributors
Updated on 04 Nov 2024
Minified
Minified + Gzipped
JavaScript (78.37%)
CSS (20.45%)
HTML (1.18%)
Cumulative downloads
Total Downloads
Last day
-0%
12,907
Compared to previous day
Last week
1%
69,834
Compared to previous week
Last month
-7.1%
296,105
Compared to previous month
Last year
-8.3%
3,979,462
Compared to previous year
1
Simple Dropdown component for React, inspired by react-select
// with npm
$ npm install react-dropdown --save
// with yarn
$ yarn add react-dropdown
If you want to support React version under v0.13, use react-dropdown@v0.6.1
This is the basic usage of react-dropdown
1import Dropdown from 'react-dropdown'; 2import 'react-dropdown/style.css'; 3 4const options = [ 5 'one', 'two', 'three' 6]; 7const defaultOption = options[0]; 8<Dropdown options={options} onChange={this._onSelect} value={defaultOption} placeholder="Select an option" />;
Options
Flat Array options
1 2const options = [ 3 'one', 'two', 'three' 4];
Object Array options
1 2const options = [ 3 { value: 'one', label: 'One' }, 4 { value: 'two', label: 'Two', className: 'myOptionClassName' }, 5 { 6 type: 'group', name: 'group1', items: [ 7 { value: 'three', label: 'Three', className: 'myOptionClassName' }, 8 { value: 'four', label: 'Four' } 9 ] 10 }, 11 { 12 type: 'group', name: 'group2', items: [ 13 { value: 'five', label: 'Five' }, 14 { value: 'six', label: 'Six' } 15 ] 16 } 17];
When using Object options you can add to each option a className string to further customize the dropdown, e.g. adding icons to options
Disabling the Dropdown
Just pass a disabled boolean value to the Dropdown to disable it. This will also give you a .Dropdown-disabled
class on the element, so you can style it yourself.
1<Dropdown disabled onChange={this._onSelect} value={defaultOption} placeholder="Select an option" />;
className
The className
prop is passed down to the wrapper div
, which also has the Dropdown-root
class.
1<Dropdown className='myClassName' />;
controlClassName
The controlClassName
prop is passed down to the control div
, which also has the Dropdown-control
class.
1<Dropdown controlClassName='myControlClassName' />;
placeholderClassName
The placeholderClassName
prop is passed down to the placeholder div
, which also has the Dropdown-placeholder
class.
1<Dropdown placeholderClassName='myPlaceholderClassName' />;
menuClassName
The menuClassName
prop is passed down to the menu div
(the one that opens and closes and holds the options), which also has the Dropdown-menu
class.
1<Dropdown menuClassName='myMenuClassName' />;
arrowClassName
The arrowClassName
prop is passed down to the arrow span
, which also has the Dropdown-arrow
class.
1<Dropdown arrowClassName='myArrowClassName' />;
arrowClosed, arrowOpen
The arrowClosed
& arrowOpen
props enable passing in custom elements for the open/closed state arrows.
1<Dropdown 2 arrowClosed={<span className="arrow-closed" />} 3 arrowOpen={<span className="arrow-open" />} 4/>;
Check more examples in the example folder.
Run example
$ npm start
MIT | Build for CSViz project @Wiredcraft
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 10/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
91 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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