Installations
npm install react-dropdown-select
Releases
update types
Published on 20 Feb 2024
"Select All" feature
Published on 25 Jul 2023
Update emotion to latest
Published on 19 Jun 2023
v4.9.2
Published on 31 Dec 2022
Update packages and docs build
Published on 27 May 2022
Update packages and docs build
Published on 27 May 2022
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
18.20.5
NPM Version
10.8.2
Statistics
352 Stars
441 Commits
82 Forks
8 Watching
41 Branches
19 Contributors
Updated on 27 Nov 2024
Bundle Size
55.41 kB
Minified
17.04 kB
Minified + Gzipped
Languages
JavaScript (98.78%)
MDX (0.53%)
Shell (0.49%)
HTML (0.21%)
Total Downloads
Cumulative downloads
Total Downloads
5,598,137
Last day
-4.3%
6,483
Compared to previous day
Last week
13%
37,521
Compared to previous week
Last month
3.4%
158,485
Compared to previous month
Last year
27%
1,721,780
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
3
Dev Dependencies
42
react-dropdown-select
Customisable dropdown select for react
Features
- configurable via
prop
s - total custom components overrides for all internals via render prop callbacks (with access to internal props, state and methods)
- stylable via css (or custom components)
- portal support for rendering dropdown outside local DOM tree. e.g. in
document.body
- auto position
- small bundle size
Installation
npm install --save react-dropdown-select
Web site
Motivation
react-select is very nice, but sometimes project requirements are beyond it's abilities
Usage
import:
import Select from "react-dropdown-select";
and use as:
1const options = [ 2 { 3 value: 1, 4 label: 'Leanne Graham' 5 }, 6 { 7 value: 2, 8 label: 'Ervin Howell' 9 } 10]; 11 12<Select options={options} onChange={(values) => this.setValues(values)} />;
If your options don't have value and label fields, include labelField and valueField in the props:
1const options = [ 2 { 3 id: 1, 4 name: 'Leanne Graham' 5 }, 6 { 7 id: 2, 8 name: 'Ervin Howell' 9 } 10]; 11 12<Select 13 options={options} 14 labelField="name" 15 valueField="id" 16 onChange={(values) => this.setValues(values)} 17/>;
options and onChange are the minimum required props
Help and Contributions
How to help/contribute
- fix issues, pull request are very welcome
- write, improve docs
- write tests (we use jest)
- suggest features and improvements
Demo
API
Component props
Prop | Type | Default | Description |
---|---|---|---|
values | array | [] | Selected values |
options | array | [] | Available options, (option with key disabled: true will be disabled) |
keepOpen | bool | false | If true, dropdown will always stay open (good for debugging) |
defaultMenuIsOpen | bool | false | If true, dropdown will be open by default |
autoFocus | bool | false | If true, and searchable , dropdown will auto focus |
clearOnBlur | bool | true | If true, and searchable , search value will be cleared on blur |
clearOnSelect | bool | true | If true, and searchable , search value will be cleared upon value select/de-select |
name | string | null | If set, input type hidden would be added in the component with the value of the name prop as name and select's values as value |
required | bool | false | If set, input type hidden would be added in the component with required prop as true/false |
pattern | string | null | If set, input type hidden would be added in the component with pattern prop as regex |
dropdownGap | number | 5 | Gap between select element and dropdown |
multi | bool | false | If true - will act as multi-select, if false - only one option will be selected at the time |
placeholder | string | "Select..." | Placeholder shown where there are no selected values |
addPlaceholder | string | "" | Secondary placeholder on search field if any value selected |
disabled | bool | false | Disable select and all interactions |
style | object | {} | Style object to pass to select |
className | string | CSS class attribute to pass to select | |
loading | bool | false | Loading indicator |
clearable | bool | false | Clear all indicator |
searchable | bool | true | If true, select will have search input text |
separator | bool | false | Separator line between close all and dropdown handle |
dropdownHandle | bool | true | Dropdown handle to open/close dropdown |
dropdownHeight | string | "300px" | Minimum height of a dropdown |
direction | string | "ltr" | direction of a dropdown "ltr", "rtl" or "auto" |
searchBy | string | label | Search by object property in values |
sortBy | string | null | Sort by object property in values |
labelField | string | "label" | Field in data to use for label |
valueField | string | "value" | Field in data to use for value |
color | string | "#0074D9" | Base color to use in component, also can be overwritten via CSS |
closeOnScroll | bool | false | If true, scrolling the page will close the dropdown |
closeOnSelect | bool | false | If true, selecting option will close the dropdown |
closeOnClickInput | bool | false | If true, clicking input will close the dropdown if you are not searching. |
dropdownPosition | string | "bottom" | Available options are "auto", "top" and "bottom" defaults to "bottom". Auto will adjust itself according Select's position on the page |
keepSelectedInList | bool | true | If false, selected item will not appear in a list |
portal | DOM element | false | If valid dom element specified - dropdown will break out to render inside the specified element |
create | bool | false | If true, select will create value from search string and fire onCreateNew callback prop |
backspaceDelete | bool | true | If true, backspace key will delete last value |
createNewLabel | string | "add {search}" | If create set to true, this will be the label of the "add new" component. {search} will be replaced by search value |
disabledLabel | string | "disabled" | Label shown on disabled field (after) the text |
selectAll | bool | false | Allow to select all |
selectAllLabel | string | "Select all" | Label for "Select all" |
clearAllLabel | string | "Clear all" | Label for "Clear all" |
additionalProps | object | null | Additional props to pass to Select |
Callback props
by using renderer props to override components some of the functionality will have to be handled manually with a help of internal props, states and methods exposed
Prop | Type | Default | Description |
---|---|---|---|
onChange | func | On values change callback, returns array of values objects | |
onDropdownClose | func | Fires upon dropdown close | |
onDropdownOpen | func | Fires upon dropdown open | |
onCreateNew | func | Fires upon creation of new item if create prop set to true | |
onClearAll | func | Fires upon clearing all values (via custom renderers) | |
onSelectAll | func | Fires upon selecting all values (via custom renderers) | |
onDropdownCloseRequest | func | undefined | Fires upon dropdown closing state, stops the closing and provides own method close() |
contentRenderer | func | Overrides internal content component (the contents of the select component) | |
itemRenderer | func | Overrides internal item in a dropdown | |
noDataRenderer | func | Overrides internal "no data" (shown where search has no results) | |
optionRenderer | func | Overrides internal option (the pillow with an "x") on the select content | |
inputRenderer | func | Overrides internal input text | |
loadingRenderer | func | Overrides internal loading | |
clearRenderer | func | Overrides internal clear button | |
separatorRenderer | func | Overrides internal separator | |
dropdownRenderer | func | Overrides internal dropdown component | |
dropdownHandleRenderer | func | Overrides internal dropdown handle | |
searchFn | func | undefined | Overrides internal search function |
handleKeyDownFn | func | undefined | Overrides internal keyDown function |
License
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gatsby.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/gatsby.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/gatsby.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/gatsby.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/npm-publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/on-pull-request.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/on-pull-request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/on-pull-request.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/sanusart/react-dropdown-select/on-pull-request.yml/master?enable=pin
- Info: 0 out of 7 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 3 out of 3 npmCommand dependencies pinned
Reason
Found 3/20 approved changesets -- score normalized to 1
Reason
1 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/gatsby.yml:1
- Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/on-pull-request.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
- Warn: branch protection not enabled for branch 'sanusart-patch-1'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 20 are checked with a SAST tool
Reason
52 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-jrvm-mcxc-mf6m
- Warn: Project is vulnerable to: GHSA-q9mw-68c2-j6m5
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-mhxj-85r3-2x55
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-7ch4-rr99-cqcw
- Warn: Project is vulnerable to: GHSA-8mmm-9v2q-x3f9
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-7hpj-7hhx-2fgx
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-rjqq-98f6-6j3r
- Warn: Project is vulnerable to: GHSA-mjxr-4v3x-q3m4
- Warn: Project is vulnerable to: GHSA-cgfm-xwp7-2cvr
- Warn: Project is vulnerable to: GHSA-rm97-x556-q36h
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-54xq-cgqr-rpm3
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-4w2v-q235-vp99
- Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-4wx3-54gh-9fr9
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Score
3
/10
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 MoreOther packages similar to react-dropdown-select
react-dropdown-tree-select
Lightweight, customizable and fast Dropdown Tree Select component for React
react-dropdown
React dropdown component
react-native-select-dropdown
react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
@radix-ui/react-dropdown-menu