Socket
Socket
Sign inDemoInstall

rc-dropdown

Package Overview
Dependencies
15
Maintainers
6
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-dropdown

dropdown ui component for react


Version published
Maintainers
6
Weekly downloads
1,246,995
decreased by-2.93%
Bundle size
21.2 kB
Minified + gzipped

Weekly downloads

Package description

What is rc-dropdown?

The rc-dropdown package is a React component that provides a flexible and customizable dropdown menu. It allows developers to create dropdown menus with various content, trigger behaviors, and alignment options.

What are rc-dropdown's main functionalities?

Basic Dropdown

This code sample demonstrates how to create a basic dropdown menu with selectable options. When an option is selected, it triggers an alert with the selected key. The visibility of the dropdown is logged to the console when it changes.

{"import React from 'react';\nimport Dropdown from 'rc-dropdown';\nimport Menu, { Item as MenuItem } from 'rc-menu';\n\nfunction onSelect({ key }) {\n  alert(`selected ${key}`);\n}\n\nfunction onVisibleChange(visible) {\n  console.log(visible);\n}\n\nconst menu = (\n  <Menu onSelect={onSelect}>\n    <MenuItem key='1'>Option 1</MenuItem>\n    <MenuItem key='2'>Option 2</MenuItem>\n    <MenuItem key='3'>Option 3</MenuItem>\n  </Menu>\n);\n\nconst App = () => (\n  <Dropdown\n    overlay={menu}\n    onVisibleChange={onVisibleChange}\n    trigger={['click']}\n  >\n    <a className='ant-dropdown-link' onClick={e => e.preventDefault()}>\n      Click me\n    </a>\n  </Dropdown>\n);\n\nexport default App;"}

Trigger Modes

This code sample shows how to create a dropdown that is triggered by hovering over the link instead of clicking. The menu appears when the user hovers over the 'Hover me' link.

{"import React from 'react';\nimport Dropdown from 'rc-dropdown';\nimport Menu, { Item as MenuItem } from 'rc-menu';\n\nconst menu = (\n  <Menu>\n    <MenuItem key='1'>Option 1</MenuItem>\n    <MenuItem key='2'>Option 2</MenuItem>\n  </Menu>\n);\n\nconst App = () => (\n  <Dropdown\n    overlay={menu}\n    trigger={['hover']}\n  >\n    <a className='ant-dropdown-link' href='#'>\n      Hover me\n    </a>\n  </Dropdown>\n);\n\nexport default App;"}

Alignment

This code sample illustrates how to align the dropdown menu relative to the trigger element. The 'align' prop is used to specify the alignment points, offset, and overflow behavior.

{"import React from 'react';\nimport Dropdown from 'rc-dropdown';\nimport Menu, { Item as MenuItem } from 'rc-menu';\n\nconst menu = (\n  <Menu>\n    <MenuItem key='1'>Option 1</MenuItem>\n    <MenuItem key='2'>Option 2</MenuItem>\n  </Menu>\n);\n\nconst App = () => (\n  <Dropdown\n    overlay={menu}\n    align={{\n      points: ['tr', 'br'],\n      offset: [0, 4],\n      overflow: { adjustX: 1, adjustY: 1 }\n    }}\n  >\n    <a className='ant-dropdown-link' href='#'>\n      Align me\n    </a>\n  </Dropdown>\n);\n\nexport default App;"}

Other packages similar to rc-dropdown

Readme

Source

rc-dropdown

react dropdown component

NPM version build status Test coverage Dependencies DevDependencies npm download bundle size dumi

Screenshot

Example

online example: http://react-component.github.io/dropdown/examples/

install

rc-dropdown

Usage

var Dropdown = require('rc-dropdown');
// use dropdown

API

props

                                       
nametypedefaultdescription
overlayClassNameStringadditional css class of root dom node
openClassNameString`${prefixCls}-open`className of trigger when dropdown is opened
prefixClsStringrc-dropdownprefix class name
transitionNameStringdropdown menu's animation css class name
animationStringpart of dropdown menu's animation css class name
placementStringbottomLeftPosition of menu item. There are: top, topCenter, topRight, bottomLeft, bottom, bottomRight
onVisibleChangeFunctioncall when visible is changed
visiblebooleanwhether tooltip is visible
defaultVisiblebooleanwhether tooltip is visible initially
overlayrc-menurc-menu element
onOverlayClickfunction(e)call when overlay is clicked
minOverlayWidthMatchTriggerbooleantrue (false when set alignPoint)whether overlay's width must not be less than trigger's
getPopupContainerFunction(menuDOMNode): HTMLElement() => document.bodyWhere to render the DOM node of dropdown

Note: Additional props are passed into the underlying rc-trigger component. This can be useful for example, to display the dropdown in a separate portal-driven window via the getDocument() rc-trigger prop.

Development

npm install
npm start

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rc-dropdown is released under the MIT license.

Keywords

FAQs

Last updated on 08 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc