• Stars
    star
    854
  • Rank 52,021 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React Select

rc-select


React Select

NPM version npm download build status Codecov bundle size dumi

Screenshots

Feature

  • support IE11+,Chrome,Firefox,Safari

Keyboard

  • Open select (focus input || focus and click)
  • KeyDown/KeyUp/Enter to navigate menu

install

rc-select

Usage

basic use

import Select, { Option } from 'rc-select';

export default () => (
  <Select>
    <Option value="jack">jack</Option>
    <Option value="lucy">lucy</Option>
    <Option value="yiminghe">yiminghe</Option>
  </Select>
);

API

Select props

name description type default
id html id to set on the component wrapper String ''
className additional css class of root dom node String ''
data-* html data attributes to set on the component wrapper String ''
prefixCls prefix class String ''
animation dropdown animation name. only support slide-up now String ''
transitionName dropdown css animation name String ''
choiceTransitionName css animation name for selected items at multiple mode String ''
dropdownMatchSelectWidth whether dropdown's width is same with select boolean true
dropdownClassName additional className applied to dropdown String -
dropdownStyle additional style applied to dropdown React.CSSProperties {}
dropdownAlign additional align applied to dropdown AlignType {}
dropdownMenuStyle additional style applied to dropdown menu Object React.CSSProperties
notFoundContent specify content to show when no result matches. ReactNode 'Not Found'
tokenSeparators separator used to tokenize on tag/multiple mode string[]?
open control select open boolean
defaultOpen control select default open boolean
placeholder select placeholder React Node
showSearch whether show search input in single mode boolean true
allowClear whether allowClear boolean { clearIcon?: ReactNode }
tags when tagging is enabled the user can select from pre-existing options or create a new tag by picking the first choice, which is what the user has typed into the search box so far. boolean false
tagRender render custom tags. (props: CustomTagProps) => ReactNode -
maxTagTextLength max tag text length to show number -
maxTagCount max tag count to show number -
maxTagPlaceholder placeholder for omitted values ReactNode/function(omittedValues) -
combobox enable combobox mode(can not set multiple at the same time) boolean false
multiple whether multiple select boolean false
disabled whether disabled select boolean false
filterOption whether filter options by input value. default filter by option's optionFilterProp prop's value boolean true/Function(inputValue:string, option:Option)
optionFilterProp which prop value of option will be used for filter if filterOption is true String 'value'
filterSort Sort function for search options sorting, see Array.sort's compareFunction. Function(optionA:Option, optionB: Option) -
optionLabelProp render option value or option children as content of select String: 'value'/'children' 'value'
defaultValue initial selected option(s) String | String[] -
value current selected option(s) String | String[] | {key:String, label:React.Node} | {key:String, label:React.Node}[] -
labelInValue whether to embed label in value, see above value type. Not support combobox mode boolean false
backfill whether backfill select option to search input (Only works in single and combobox mode) boolean false
onChange called when select an option or input value change(combobox) function(value, option:Option | Option[]) -
onSearch called when input changed function -
onBlur called when blur function -
onFocus called when focus function -
onPopupScroll called when menu is scrolled function -
onSelect called when a option is selected. param is option's value and option instance Function(value, option:Option) -
onDeselect called when a option is deselected. param is option's value. only called for multiple or tags Function(value, option:Option) -
onInputKeyDown called when key down on input Function(event) -
defaultActiveFirstOption whether active first option by default boolean true
getPopupContainer container which popup select menu rendered into function(trigger:Node):Node function(){return document.body;}
getInputElement customize input element function(): Element -
showAction actions trigger the dropdown to show String[]? -
autoFocus focus select after mount boolean -
autoClearSearchValue auto clear search input value when multiple select is selected/deselected boolean true
suffixIcon specify the select arrow icon ReactNode -
clearIcon specify the clear icon ReactNode -
removeIcon specify the remove icon ReactNode -
menuItemSelectedIcon specify the item selected icon ReactNode | (props: MenuItemProps) => ReactNode -
dropdownRender render custom dropdown menu (menu: React.Node, props: MenuProps) => ReactNode -
loading show loading icon in arrow boolean false
virtual Disable virtual scroll boolean true
direction direction of dropdown 'ltr' | 'rtl' 'ltr'

Methods

name description parameters return
focus focus select programmably - -
blur blur select programmably - -

Option props

name description type default
className additional class to option String ''
disabled no effect for click or keydown for this item boolean false
key if react want you to set key, then key is same as value, you can omit value String/number -
value default filter by this attribute. if react want you to set key, then key is same as value, you can omit value String/number -
title if you are not satisfied with auto-generated title which is show while hovering on selected value, you can customize it with this property String -

OptGroup props

name description type default
label group label String/React.Element -
key - String -
value default filter by this attribute. if react want you to set key, then key is same as value, you can omit value String -

Development

npm install
npm start

Example

local example: http://localhost:9001/

online example: http://select.react-component.now.sh/

Test Case

npm test

Coverage

npm run coverage

License

rc-select is released under the MIT license.

More Repositories

1

slider

React Slider
JavaScript
2,962
star
2

form

React High Order Form Component(web & react-native)
JavaScript
1,799
star
3

calendar

React Calendar
JavaScript
1,681
star
4

table

React Table
TypeScript
1,183
star
5

tree

React Tree
TypeScript
1,113
star
6

field-form

⚡️ React Performance First Form Component
TypeScript
914
star
7

tooltip

React Tooltip
TypeScript
896
star
8

upload

React Upload
TypeScript
766
star
9

progress

React Progress Bar
TypeScript
678
star
10

animate

anim react element easily
JavaScript
675
star
11

menu

React Menu
TypeScript
655
star
12

virtual-list

🧾 React Virtual List Component which worked with animation
TypeScript
645
star
13

pagination

React Pagination
TypeScript
629
star
14

util

Common Utils For React Component
TypeScript
604
star
15

tabs

React Tabs
TypeScript
540
star
16

queue-anim

Animate React Component in queue
TypeScript
474
star
17

time-picker

React TimePicker
JavaScript
463
star
18

dialog

React Dialog
TypeScript
424
star
19

color-picker

React ColorPicker
TypeScript
422
star
20

m-date-picker

React Mobile DatePicker(web & react-native)
TypeScript
400
star
21

react-component.github.io

docs and site of react-component
HTML
378
star
22

drawer

React Drawer
TypeScript
372
star
23

tween-one

Animate One React Element
TypeScript
370
star
24

notification

React Notification
TypeScript
364
star
25

trigger

Abstract React Trigger
TypeScript
345
star
26

collapse

React Collapse / Accordion
TypeScript
319
star
27

steps

React Steps
TypeScript
311
star
28

scroll-anim

Animate Scroll React Component
JavaScript
301
star
29

input-number

React Input Number
TypeScript
296
star
30

tree-select

React Tree Select
TypeScript
272
star
31

picker

📅 All Date Pickers you need.
TypeScript
253
star
32

m-picker

React Mobile Picker(web & react-native)
TypeScript
246
star
33

swipeout

React Swipeout(web & react-native)
TypeScript
213
star
34

rc-tools

Tools For React Component
JavaScript
205
star
35

cascader

cascade select in one box
TypeScript
198
star
36

switch

React Switch
JavaScript
187
star
37

image

🖼 React Image Component
TypeScript
179
star
38

banner-anim

Animate Banner React Component
JavaScript
170
star
39

m-pull-to-refresh

React Mobile Pull To Refresh
TypeScript
166
star
40

dropdown

React Dropdown
TypeScript
163
star
41

texty

React Text Animate
TypeScript
154
star
42

resize-observer

👓 Resize observer for React
JavaScript
153
star
43

m-tabs

React Mobile Tabs Component (web & react-native)
TypeScript
139
star
44

checkbox

React Checkbox
TypeScript
130
star
45

motion

⛷ CSS Animation for React
TypeScript
120
star
46

gesture

Support gesture for react component.
TypeScript
103
star
47

rate

React Rate
JavaScript
91
star
48

form-validation

This project is deprecated, you can try https://github.com/react-component/form
JavaScript
86
star
49

m-list-view

ReactNative ListView Web Port
JavaScript
85
star
50

footer

🐾 Pretty Footer react component used in ant.design
JavaScript
83
star
51

align

Abstract React Align
TypeScript
81
star
52

mentions

React Mentions
TypeScript
67
star
53

rn-packager

Standalone ReactNative Packager
JavaScript
66
star
54

generator-rc

yeoman generator for react component
JavaScript
58
star
55

editor-core

a draft-js based editor
TypeScript
56
star
56

m-drawer

React Drawer
JavaScript
54
star
57

cropping

image cropping
TypeScript
54
star
58

editor-mention

React Mention
JavaScript
53
star
59

m-cascader

React Mobile Cascader Component(web and react-native)
TypeScript
51
star
60

m-dialog

React Mobile Dialog(web & react-native)
TypeScript
45
star
61

spider

React Tree Diagrams
JavaScript
44
star
62

overflow

📦 Auto collapse box util component
TypeScript
42
star
63

css-transition-group

standalone CSSTransitionGroup for React.addons.CSSTransitionGroup
JavaScript
38
star
64

m-calendar

React Mobile Calendar Component (web)
TypeScript
36
star
65

m-feedback

:active pseudo-class with react for mobile
TypeScript
36
star
66

input

React Input Component
TypeScript
32
star
67

tour

TypeScript
30
star
68

pager

React Pager
JavaScript
26
star
69

m-notification

JavaScript
23
star
70

dropzone

React Dropzone
JavaScript
23
star
71

textarea

React Textarea
TypeScript
22
star
72

radio

[DEPRECATED] React Radio
CSS
19
star
73

m-input-number

input-number mobile ui component for react (web & react-native)
TypeScript
17
star
74

portal

TypeScript
16
star
75

touchable

React Touchable Component
TypeScript
16
star
76

rc-server

This project is deprecated, use rc-tools run server
JavaScript
15
star
77

gulp-jsx2example

Compile JSX file to HTML (react demo)
JavaScript
13
star
78

cascade-select

React CascadeSelect
JavaScript
13
star
79

icon-anim

Icon cutover or morph animate React Element
JavaScript
12
star
80

m-select-list

React Mobile Select List Component
JavaScript
12
star
81

segmented

React Segmented Controls
TypeScript
12
star
82

rc-test

test react component
JavaScript
11
star
83

mobile

ant design mobile components
TypeScript
10
star
84

m-tooltip

React Tooltip for mobile
TypeScript
8
star
85

context

TypeScript
7
star
86

rn-tools

tools for react-native
JavaScript
7
star
87

m-trigger

React Trigger Component for mobile
JavaScript
6
star
88

rn-core

Standalone ReactNative Framework
Objective-C
6
star
89

record

Record audio from microphone
JavaScript
5
star
90

.github

5
star
91

RNPlayground

react-native playground container
Objective-C
5
star
92

mutate-observer

TypeScript
5
star
93

editor-plugin-emoji

HTML
4
star
94

m-steps

React Steps for mobile
CSS
4
star
95

editor-plugin-basic-style

TypeScript
3
star
96

mini-decimal

TypeScript
3
star
97

editor-utils

editor utilities
TypeScript
2
star
98

father-plugin

father plugin for all react-component project
TypeScript
1
star
99

editor-plugin-image

TypeScript
1
star