All Projects → dbilgili → Custom Reactjs Dropdown Components

dbilgili / Custom Reactjs Dropdown Components

Custom dropdown components for ReactJS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Custom Reactjs Dropdown Components

Accordion
Silky-smooth accordion widgets with no external dependencies.
Stars: ✭ 32 (-70.91%)
Mutual labels:  dropdown, menu
Easydropdown
A lightweight library for building beautiful styleable <select> elements
Stars: ✭ 337 (+206.36%)
Mutual labels:  menu, dropdown
Menu
The most customizable menu for macOS apps.
Stars: ✭ 84 (-23.64%)
Mutual labels:  dropdown, menu
clicky-menus
Simple click-triggered navigation submenus. Accessible and progressively enhanced.
Stars: ✭ 76 (-30.91%)
Mutual labels:  dropdown, menu
Ember Select Box
🔠 A faux select box for Ember apps
Stars: ✭ 60 (-45.45%)
Mutual labels:  menu, dropdown
ContextMenuSwift
A better version of iOS 13 Context Menu
Stars: ✭ 162 (+47.27%)
Mutual labels:  dropdown, menu
Vue Stripe Menu
Creating a navigation menu with animations like on Stripe
Stars: ✭ 266 (+141.82%)
Mutual labels:  menu, dropdown
React Native Dropdown Picker
A single / multiple, categorizable & searchable item picker (dropdown) component for react native which supports both Android & iOS.
Stars: ✭ 230 (+109.09%)
Mutual labels:  menu, dropdown
Tippyjs React
React component for Tippy.js (official)
Stars: ✭ 1,081 (+882.73%)
Mutual labels:  menu, dropdown
Kpdropmenu
KPDropMenu is an Objective-C port of HADropDown With Additional features
Stars: ✭ 50 (-54.55%)
Mutual labels:  menu, dropdown
Easydropdown
💧 Fantastic dropdown in Swift
Stars: ✭ 254 (+130.91%)
Mutual labels:  menu, dropdown
Igldropdownmenu
An iOS drop down menu with pretty animation and easy to customize.
Stars: ✭ 1,218 (+1007.27%)
Mutual labels:  menu, dropdown
Dropdownmenukit
UIKit drop down menu, simple yet flexible and written in Swift
Stars: ✭ 246 (+123.64%)
Mutual labels:  menu, dropdown
react-native-select-pro
React Native dropdown (select) component developed by Mobile Reality
Stars: ✭ 79 (-28.18%)
Mutual labels:  dropdown, menu
React Menu
React component for building accessible menu, dropdown, submenu, context menu and more.
Stars: ✭ 237 (+115.45%)
Mutual labels:  menu, dropdown
react-native-panel
A Customizable React Native Panel for Android and iOS
Stars: ✭ 35 (-68.18%)
Mutual labels:  dropdown, menu
React Dropdown Select
Customisable dropdown select for react
Stars: ✭ 227 (+106.36%)
Mutual labels:  menu, dropdown
Ifmmenu
仿微信添加菜单
Stars: ✭ 235 (+113.64%)
Mutual labels:  menu, dropdown
Dropdownmenu
DropDownMenu for Android,Filter the list based on multiple condition.
Stars: ✭ 815 (+640.91%)
Mutual labels:  menu, dropdown
Tippyjs
Tooltip, popover, dropdown, and menu library
Stars: ✭ 9,433 (+8475.45%)
Mutual labels:  menu, dropdown

This package features two custom dropdown menu components for ReactJS.

WARNING: Breaking changes take effect from version 1.1.7. If you are using any of the earlier versions, refer to the previous README files.

Online demo

Single-selection Multi-selection
Single-selection searchable Multi-selection searchable

Installation

npm install --save reactjs-dropdown-component

Usage

Import the component you want to use;

import { DropdownMultiple, Dropdown } from 'reactjs-dropdown-component';

If you are using NextJS, import them dynamically instead;

import dynamic from 'next/dynamic';

const Dropdown = dynamic(
  async () => {
    const module = await import('reactjs-dropdown-component');
    const DD = module.Dropdown;

    return ({ forwardedRef, ...props }) => <DD ref={forwardedRef} {...props} />;
  },
  { ssr: false },
);

const DropdownMultiple = dynamic(
  async () => {
    const module = await import('reactjs-dropdown-component');
    const DDM = module.DropdownMultiple;

    return ({ forwardedRef, ...props }) => <DDM ref={forwardedRef} {...props} />;
  },
  { ssr: false },
);

The shape of the objects in the data array should be as follows:

const locations = [
  {
    label: 'New York',
    value: 'newYork',
  },
  {
    label: 'Oslo',
    value: 'oslo',
  },
  {
    label: 'Istanbul',
    value: 'istanbul',
  }
];

Use a function to pass to onChange prop. For <Dropdown> component item is an object, whereas for <DropdownMultiple> it is an array of objects.

  onChange = (item, name) => {
    ...
  }

Finally use the components as follows:

<Dropdown
  name="location"
  title="Select location"
  list={locations}
  onChange={this.onChange}
/>

<DropdownMultiple
  name="location"
  title="Select location"
  titleSingular="location"
  list={locations}
  onChange={this.onChange}
/>

Note that when multiple options are selected in <DropdownMultiple>, titleSingular value automatically becomes the plural form of the noun. If you want to use a custom plural title, define titlePlural as well.

<DropdownMultiple
  name="location"
  title="Velg sted"
  titleSingular="Sted"
  titlePlural="Steder"
  list={locations}
  onChange={this.onChange}
/>

Search functionality

Using searchable prop enables the search bar. Pass an array of strings corresponding to place holder and not found message respectively.

<Dropdown
  name="location"
  title="Select location"
  searchable={["Search for location", "No matching location"]}
  list={locations}
  onChange={this.onChange}
/>

Selecting item(s) by default

Use the select prop to define the initally selected item(s).

For <Dropdown>

select={{value: 'istanbul'}}

For <DropdownMultiple>

select={[{value: 'oslo'}, {value: 'istanbul'}]}

Calling internal functions

Pass a ref and use it to call the internal functions.

For <Dropdown>

<Dropdown
  ref={this.dropdownRef}
  ...
/>

this.dropdownRef.current.selectSingleItem({ value: 'oslo' });
this.dropdownRef.current.clearSelection();

For <DropdownMultiple>

<DropdownMultiple
  ref={this.dropdownRef}
  ...
/>

this.dropdownRef.current.selectMultipleItems([
  { value: 'istanbul' }
  { value: 'oslo' },
]);

this.dropdownRef.current.selectAll();
this.dropdownRef.current.deselectAll();

Custom styling

Use the following keys in an object passed to styles prop

wrapper
header
headerTitle
headerArrowUpIcon
headerArrowDownIcon
checkIcon
list
listSearchBar
scrollList
listItem
listItemNoResult

Example:

<Dropdown
  name="location"
  title="Select location"
  list={locations}
  onChange={this.onChange}
  styles={{
    headerTitle: { color: 'red' }
  }}
/>

Note that styles prop is meant for basic styling. Use stylesheet by targeting the specific class names for more complicated stylings.

Use id prop to set an additional class name to every element in the dropdown menu. That way you can style multiple dropdown menus with different stylings rules.

In order to define your own arrow and check icons, use arrowUpIcon, arrowDownIcon and checkIcon props. These props accept an element type.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].