Skip to content

Repository files navigation

@rc-component/dropdown

Ant Design Part of the Ant Design ecosystem.

🔽 A trigger-driven dropdown component for React.

NPM versionnpm downloadsbuild statusCodecovbundle sizedumi

English | 简体中文

Highlights

  • Built on @rc-component/trigger.
  • Supports hover, click, context menu, and custom trigger actions.
  • Accepts a React element or render function as dropdown overlay.
  • Supports align point behavior and trigger-width matching.

Install

npm install @rc-component/dropdown

Usage

importDropdownfrom'@rc-component/dropdown';import'@rc-component/dropdown/assets/index.css';exportdefaultfunctionApp(){return(<Dropdownoverlay={<div>Dropdown content</div>}trigger={['click']}><buttontype="button">Open</button></Dropdown>);}

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

Additional props are passed to the underlying @rc-component/trigger component.

PropertyDescriptionTypeDefault
alignPointAlign popup to the click pointbooleanfalse
animationPopup animation namestring-
arrowWhether to show dropdown arrowbooleanfalse
getPopupContainerContainer where dropdown is rendered(node: HTMLElement) => HTMLElement() => document.body
minOverlayWidthMatchTriggerWhether overlay width should be at least trigger widthbooleantrue unless alignPoint is set
openClassNameClass name added to trigger when dropdown is openstring${prefixCls}-open
overlayDropdown overlayReact.ReactElement | (() => React.ReactElement)-
overlayClassNameAdditional overlay class namestring-
overlayStyleOverlay styleReact.CSSProperties-
placementDropdown placementstringbottomLeft
prefixClsComponent class name prefixstringrc-dropdown
transitionNamePopup transition class namestring-
triggerTrigger actionActionType | ActionType[]['hover']
visibleControlled visible stateboolean-
onOverlayClickCallback when overlay is clicked(event: Event) => void-
onVisibleChangeCallback when visibility changes(visible: boolean) => void-

Development

npm install
npm start

The dumi site runs at http://localhost:8000 by default.

npm test
npm run tsc
npm run lint
npm run compile
npm run build

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/dropdown is released under the MIT license.

About

🔽 A trigger-driven dropdown component for React.

Topics

Resources

Stars

181 stars

Watchers

23 watching

Forks

Releases

Packages

Used by

Contributors

Languages