Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-cascader

Package Overview
Dependencies
Maintainers
5
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-cascader

cascade select ui component for react

  • 3.30.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
decreased by-0.77%
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

Keywords

FAQs

Package last updated on 29 Oct 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc