🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

rc-cascader

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-cascader

cascade select ui component for react

3.34.0
latest
Version published
Weekly downloads
1.4M
-25.1%
Maintainers
5
Weekly downloads
 
Created

What is rc-cascader?

The rc-cascader package is a React component for creating cascading drop-down menus. It allows users to select options from a hierarchical structure, which is useful for selecting nested categories or locations.

What are rc-cascader's main functionalities?

Basic Cascading Menu

This code sample demonstrates how to create a basic cascading menu with the rc-cascader package. The 'options' array defines the hierarchical structure of the menu, and the 'onChange' function logs the selected value.

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

const options = [
  {
    value: 'zhejiang',
    label: 'Zhejiang',
    children: [
      {
        value: 'hangzhou',
        label: 'Hangzhou',
        children: [
          {
            value: 'xihu',
            label: 'West Lake',
          },
        ],
      },
    ],
  },
  {
    value: 'jiangsu',
    label: 'Jiangsu',
    children: [
      {
        value: 'nanjing',
        label: 'Nanjing',
        children: [
          {
            value: 'zhonghuamen',
            label: 'Zhong Hua Men',
          },
        ],
      },
    ],
  },
];

function onChange(value) {
  console.log(value);
}

const App = () => (
  <Cascader options={options} onChange={onChange} />
);

export default App;

Custom Trigger

This code sample shows how to use a custom trigger, such as a button, to open the cascading menu. The children of the Cascader component determine the trigger element.

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

const options = [/* ... */];

const App = () => (
  <Cascader options={options}>
    <button>Click me to select</button>
  </Cascader>
);

export default App;

Search and Filter

This code sample illustrates how to enable a search and filter functionality within the cascading menu by setting the 'showSearch' prop to true. This allows users to quickly find options by typing.

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

const options = [/* ... */];

const App = () => (
  <Cascader options={options} showSearch />
);

export default App;

Other packages similar to rc-cascader

FAQs

Package last updated on 01 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts