@core-rc/rc-select

中文文档
0.1.4发布于 2025/08/14MITTypeScriptESM + CJS近 30 天下载 4190

React Select

原始使用文档
文档目录15 节
  1. Feature
  2. Keyboard
  3. install
  4. Usage
  5. basic use
  6. API
  7. Select props
  8. Methods
  9. Option props
  10. OptGroup props
  11. Development
  12. Example
  13. Test Case
  14. Coverage
  15. License

@core-rc/rc-select


React Select Component.

Feature

  • support IE11+,Chrome,Firefox,Safari

Keyboard

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

install

yarn add @core-rc/rc-select

or

npm install @core-rc/rc-select

Usage

basic use

import Select, { Option } from '@core-rc/rc-select';
import '@core-rc/rc-select/assets/index.css';

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

API

Select props

namedescriptiontypedefault
idhtml id to set on the component wrapperString''
classNameadditional css class of root dom nodeString''
data-*html data attributes to set on the component wrapperString''
prefixClsprefix classString''
animationdropdown animation name. only support slide-up nowString''
transitionNamedropdown css animation nameString''
choiceTransitionNamecss animation name for selected items at multiple modeString''
dropdownMatchSelectWidthwhether dropdown's width is same with selectbooleantrue
dropdownClassNameadditional className applied to dropdownString-
dropdownStyleadditional style applied to dropdownReact.CSSProperties{}
dropdownAlignadditional align applied to dropdownAlignType{}
dropdownMenuStyleadditional style applied to dropdown menuObjectReact.CSSProperties
notFoundContentspecify content to show when no result matches.ReactNode'Not Found'
tokenSeparatorsseparator used to tokenize on tag/multiple modestring[]?
opencontrol select openboolean
defaultOpencontrol select default openboolean
placeholderselect placeholderReact Node
showSearchwhether show search input in single modebooleantrue
allowClearwhether allowClearboolean{ clearIcon?: ReactNode }
tagswhen 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.booleanfalse
tagRenderrender custom tags.(props: CustomTagProps) => ReactNode-
maxTagTextLengthmax tag text length to shownumber-
maxTagCountmax tag count to shownumber-
maxTagPlaceholderplaceholder for omitted valuesReactNode/function(omittedValues)-
comboboxenable combobox mode(can not set multiple at the same time)booleanfalse
multiplewhether multiple selectbooleanfalse
disabledwhether disabled selectbooleanfalse
filterOptionwhether filter options by input value. default filter by option's optionFilterProp prop's valuebooleantrue/Function(inputValue:string, option:Option)
optionFilterPropwhich prop value of option will be used for filter if filterOption is trueString'value'
filterSortSort function for search options sorting, see Array.sort's compareFunction.Function(optionA:Option, optionB: Option)-
optionLabelProprender option value or option children as content of selectString: 'value'/'children''value'
defaultValueinitial selected option(s)String | String[]-
valuecurrent selected option(s)String | String[] | {key:String, label:React.Node} | {key:String, label:React.Node}[]-
labelInValuewhether to embed label in value, see above value type. Not support combobox modebooleanfalse
backfillwhether backfill select option to search input (Only works in single and combobox mode)booleanfalse
onChangecalled when select an option or input value change(combobox)function(value, option:Option | Option[])-
onSearchcalled when input changedfunction-
onBlurcalled when blurfunction-
onFocuscalled when focusfunction-
onPopupScrollcalled when menu is scrolledfunction-
onSelectcalled when a option is selected. param is option's value and option instanceFunction(value, option:Option)-
onDeselectcalled when a option is deselected. param is option's value. only called for multiple or tagsFunction(value, option:Option)-
onInputKeyDowncalled when key down on inputFunction(event)-
defaultActiveFirstOptionwhether active first option by defaultbooleantrue
getPopupContainercontainer which popup select menu rendered intofunction(trigger:Node):Nodefunction(){return document.body;}
getInputElementcustomize input elementfunction(): Element-
showActionactions trigger the dropdown to showString[]?-
autoFocusfocus select after mountboolean-
autoClearSearchValueauto clear search input value when multiple select is selected/deselectedbooleantrue
prefixspecify the select prefix icon or textReactNode-
suffixIconspecify the select arrow iconReactNode-
clearIconspecify the clear iconReactNode-
removeIconspecify the remove iconReactNode-
menuItemSelectedIconspecify the item selected iconReactNode | (props: MenuItemProps) => ReactNode-
dropdownRenderrender custom dropdown menu(menu: React.Node) => ReactNode-
loadingshow loading icon in arrowbooleanfalse
virtualDisable virtual scrollbooleantrue
directiondirection of dropdown'ltr' | 'rtl''ltr'
optionRenderCustom rendering options(oriOption: FlattenOptionData<BaseOptionType> , info: { index: number }) => React.ReactNode-
labelRenderCustom rendering label(props: LabelInValueType) => React.ReactNode-
maxCountThe max number of items can be selectednumber-

Methods

namedescriptionparametersreturn
focusfocus select programmably--
blurblur select programmably--

Option props

namedescriptiontypedefault
classNameadditional class to optionString''
disabledno effect for click or keydown for this itembooleanfalse
keyif react want you to set key, then key is same as value, you can omit valueString/number-
valuedefault filter by this attribute. if react want you to set key, then key is same as value, you can omit valueString/number-
titleif you are not satisfied with auto-generated title which is show while hovering on selected value, you can customize it with this propertyString-

OptGroup props

namedescriptiontypedefault
labelgroup labelString/React.Element-
key-String-
valuedefault filter by this attribute. if react want you to set key, then key is same as value, you can omit valueString-
classNamesame as Option propsString''
titlesame as Option propsString-

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

@core-rc/rc-select is released under the MIT license.

版本与发布记录

@core-rc/rc-select 共发布 13 个版本,首次发布于 2024/12/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.4latest2025/08/141.2 年前
0.1.32025/06/251.4 年前
0.1.22025/03/221.6 年前
0.1.12025/03/211.6 年前
0.1.1-0next2025/03/211.6 年前
0.1.02025/03/211.6 年前

关于 @core-rc/rc-select 的常见问题

@core-rc/rc-select 是什么?

React Select

如何安装 @core-rc/rc-select?

在项目目录运行 npm install @core-rc/rc-select,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.9.0)、react-dom(>=16.9.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@core-rc/rc-select 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@core-rc/rc-select 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@core-rc/rc-select 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=8.x。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@core-rc/rc-select 可以商用吗?

@core-rc/rc-select 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@core-rc/rc-select 的下载量有多少?

根据 npm 官方下载统计,@core-rc/rc-select 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,190 次,日均约 140 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@core-rc/rc-select 还在维护吗?

最新版本 0.1.4 发布于 2025/08/14(1.2 年前);至今共发布 13 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/12/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。