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

react-dropdown-cascade

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dropdown-cascade

A [React](https://reactjs.org) component inpired by [rc-cascader](https://www.npmjs.com/package/rc-cascader) and without external dependencies.

1.0.0
Source
npm
Version published
Weekly downloads
441
-3.5%
Maintainers
1
Weekly downloads
 
Created
Source

react-dropdown-cascade

A React component inpired by rc-cascader and without external dependencies.

Installation

npm install react-dropdown-cascade --save

or

yarn add react-dropdown-cascade

Usage

import React from 'react';
import DropdownCascade from 'react-dropdown-cascade';

const items = [
  {
    value: '1',
    label: 'Menu 1',
    children: [
      {
        value: '11',
        label: 'Another Item'
      },
      {
        value: '12',
        label: 'More Items',
        children: [
          {
            value: '121',
            label: 'Sub Item A'
          },
          {
            value: '122',
            label: 'Sub Item B',
            disabled: true
          },
          {
            value: '123',
            label: 'Sub Item C'
          }
        ]
      }
    ]
  },
  {
    value: '2',
    label: 'Menu 2'
  },
  {
    value: '3',
    label: 'Menu 3',
    children: [
      {
        value: '31',
        label: 'Hello'
      },
      {
        value: '21',
        label: 'World'
      }
    ]
  }
];

export default function App() {
  return (
    <>
      <h1 style={{ margin: 15 }}>react-dropdown-cascade</h1>
      <DropdownCascade
        dropdownStyle={{ margin: '5px 20px 15px 20px' }}
        items={items}
        onSelect={(value, selectedItems) => console.log(value, selectedItems)}
      >
        <input placeholder="Click here" style={{ height: 24, width: 300 }} />
      </DropdownCascade>
    </>
  );
}

Screenshots

API

Props

PropTypeRequiredDefaultDescription
defaultValuestringnoundefinedInitial value
dropdownClassNamestringnoundefinedThe additional className of dropdown
dropdownStyleCSSPropertiesnoundefinedThe additional style of dropdown
dropdownMenuClassNamestringnoundefinedThe additional className of dropdown menu
dropdownMenuStyleCSSPropertiesnoundefinedThe additional style of dropdown menu
dropdownMenuItemClassNamestringnoundefinedThe additional className of dropdown menu item
dropdownMenuItemStyleCSSPropertiesnoundefinedThe additional style of dropdown menu item
dropdownSubItemClassNamestringnoundefinedThe additional className of dropdown subitem
dropdownSubItemStyleCSSPropertiesnoundefinedThe additional style of dropdown subitem
expandTrigger"click" | "hover"no"click"Trigger that shows the dropdown
itemsItem[]yesThe data for cascade
onSelect(value: string, selectedItems: Item[]) => void;noundefinedCallback when selecting an item

Item

interface Item {
  value: string;
  label: string;
  disabled?: boolean;
  children?: Item[];
}

License

MIT

Keywords

cascade

FAQs

Package last updated on 06 Jan 2021

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