Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rc-cascader

react-component6.3mMIT3.33.1TypeScript support: included

cascade select ui component for react

react, react-component, react-cascader, react-select, select, cascade, cascader

readme

rc-cascader

React Cascader Component.

NPM version npm download build status Codecov bundle size dumi

Browser Support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

Screenshots

Example

https://cascader-react-component.vercel.app

Install

rc-cascader

$ npm install rc-cascader --save

Usage

import React from 'react';
import Cascader from 'rc-cascader';

const options = [{
  'label': '福建',
  'value': 'fj',
  'children': [{
    'label': '福州',
    'value': 'fuzhou',
    'children': [{
      'label': '马尾',
      'value': 'mawei',
    }],
  }, {
    'label': '泉州',
    'value': 'quanzhou',
  }],
}, {
  'label': '浙江',
  'value': 'zj',
  'children': [{
    'label': '杭州',
    'value': 'hangzhou',
    'children': [{
      'label': '余杭',
      'value': 'yuhang',
    }],
  }],
}, {
  'label': '北京',
  'value': 'bj',
  'children': [{
    'label': '朝阳区',
    'value': 'chaoyang',
  }, {
    'label': '海淀区',
    'value': 'haidian',
  }],
}];

React.render(
  <Cascader options={options}>
    ...
  </Cascader>
, container);

API

props

name type default description
autoClearSearchValue boolean true Whether the current search will be cleared on selecting an item. Only applies when checkable
options Object The data options of cascade
value Array selected value
defaultValue Array initial selected value
onChange Function(value, selectedOptions) callback when finishing cascader select
changeOnSelect Boolean false change value on each selection
loadData Function(selectedOptions) callback when click any option, use for loading more options
expandTrigger String 'click' expand current item when click or hover
open Boolean visibility of popup overlay
onDropdownVisibleChange Function(visible) callback when popup overlay's visibility changed
transitionName String transition className like "slide-up"
prefixCls String rc-cascader prefix className of popup overlay
dropdownClassName String additional className of popup overlay
popupPlacement String bottomLeft use preset popup align config from builtinPlacements:bottomRight topRight bottomLeft topLeft
getPopupContainer function(trigger:Node):Node () => document.body container which popup select menu rendered into
dropdownMenuColumnStyle Object style object for each cascader pop menu
fieldNames Object { label: 'label', value: 'value', children: 'children' } custom field name for label and value and children
expandIcon ReactNode > specific the default expand icon
loadingIcon ReactNode > specific the default loading icon
hidePopupOnSelect Boolean >true hide popup on select

option

name type default description
label String option text to display
value String option value as react key
disabled Boolean disabled option
children Array children options

Development

$ npm install
$ npm start

Test Case

$ npm test

Coverage

$ npm run coverage

License

rc-cascader is released under the MIT license.

changelog

History

0.17.0 / 2018/12/14

  • should close popup on double click when changeOnSelect is set

0.16.0 / 2018/08/23

  • Add loadingIcon.

0.15.0 / 2018/08/10

  • Add expandIcon.

0.14.0 / 2018/07/03

0.13.0 / 2018/04/27

  • Allow to custom the field name of options. #23

0.12.0

  • Add es build
  • support React 16

0.11.0 / 2017-01-17

  • Add Keyboard support

0.10.0 / 2016-08-20

  • Add dropdownMenuColumnStyle
  • Fix changeOnSelect when load data dynamicly

0.9.0 / 2016-02-19

  • support popupPlacement

0.8.0 / 2016-01-26

  • Add prop changeOnSelect

0.7.0 / 2016-01-25

  • Support disabled item

0.6.1 / 2016-01-18

  • Hide popup menu when there is no options, fix #4

0.6.0 / 2016-01-05

  • Add prop disabled.

0.5.1 / 2015-12-31

  • Always scroll to show active menu item

0.5.0 / 2015-12-30

  • Remove onSelect
  • Add loadData for dynamicly changing options

0.4.0 / 2015-12-29

  • Add prop popupVisible.
  • onVisibleChange => onPopupVisibleChange.

0.3.0 / 2015-12-28

  • Fix value and defaultValue.
  • Add Test Cases.

0.2.0 / 2015-12-25

  • Add prop expandTrigger.

0.1.0 / 2015-12-25

First release.