Socket
Socket
Sign inDemoInstall

rc-dropdown

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-dropdown

dropdown ui component for react


Version published
Weekly downloads
1.5M
increased by8.07%
Maintainers
2
Weekly downloads
 
Created

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

Keywords

FAQs

Package last updated on 17 Sep 2017

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