Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@commercetools-uikit/dropdown-menu
Advanced tools
The Dropdown Menu component represents a component that triggers the rendering of a floating menu.
This component should be used whenever you need to display a floating panel after clicking on an element.
It allows to use any component as the element used to trigger the floating panel.
The panel can be customized to render whatever is needed. However, as a common use case would be to render a list of elements and select one of them, this component provides some helpers to easily implement such use case.
Something to bear in mind is that, when the panel is open, the document scroll is blocked.
yarn add @commercetools-uikit/dropdown-menu
npm --save install @commercetools-uikit/dropdown-menu
Additionally install the peer dependencies (if not present)
yarn add react
npm --save install react
import CheckboxInput from '@commercetools-uikit/checkbox-input';
import DropdownMenu from '@commercetools-uikit/dropdown-menu';
import IconButton from '@commercetools-uikit/icon-button';
import SecondaryButton from '@commercetools-uikit/secondary-button';
import SpacingsStack from '@commercetools-uikit/spacings-stack';
import Text from '@commercetools-uikit/text';
import { ColumnsIcon, FilterIcon } from '@commercetools-uikit/icons';
export const ListDropdownExample = () => {
return (
<DropdownMenu
triggerElement={<IconButton icon={<ColumnsIcon />} label="list" />}
menuHorizontalConstraint={6}
menuPosition="left"
menuType="list"
>
<DropdownMenu.ListMenuItem onClick={() => {}}>
Option 1
</DropdownMenu.ListMenuItem>
<DropdownMenu.ListMenuItem onClick={() => {}} isDisabled>
Option 2
</DropdownMenu.ListMenuItem>
<DropdownMenu.ListMenuItem onClick={() => {}}>
Option 3
</DropdownMenu.ListMenuItem>
</DropdownMenu>
);
};
export const CustomDropdownExample = () => {
return (
<DropdownMenu
triggerElement={
<SecondaryButton label="Filters" iconLeft={<FilterIcon />} />
}
menuHorizontalConstraint={6}
menuPosition="right"
>
<SpacingsStack scale="m">
<Text.Body>Store</Text.Body>
<CheckboxInput isChecked value="store" onChange={(event) => {}}>
Canada (FR)
</CheckboxInput>
</SpacingsStack>
</DropdownMenu>
);
};
Props | Type | Required | Default | Description |
---|---|---|---|---|
menuPosition | union Possible values: 'left' , 'right' | 'left' | The position of the menu relative to the trigger element. | |
menuMaxHeight | number | The maximum height for the menu in pixels. By default, the max height will be the available space between the trigger element and the bottom of the viewport. | ||
triggerElement | ReactElement | ✅ | The element that triggers the dropdown. | |
menuType | union Possible values: 'default' , 'list' | 'default' | The type of the menu. The 'default' type just renders a dropdown container but the 'list' type is intended to be used with the DropdownMenu.ListMenuItem component. | |
menuHorizontalConstraint | TMaxProp | 'auto' | The horizontal constraint of the menu. | |
children | ReactNode | ✅ | The content of the dropdown. |
When using the list floating panel, the DropdownMenu
component exposes an inner sub-component called DropdownMenu.ListMenuItem
that should be used to render each item in the list.
Clicking on an item will close the panel and call the onClick
callback with the item's value.
Props | Type | Required | Default | Description |
---|---|---|---|---|
isDisabled | boolean | false | Whether the item should be disabled. | |
onClick | () => void | A callback to be called when the item is clicked. | ||
children | string | ✅ | The label for the item. |
FAQs
The Dropdown Menu component represents a component that triggers the rendering of a floating menu.
The npm package @commercetools-uikit/dropdown-menu receives a total of 2,397 weekly downloads. As such, @commercetools-uikit/dropdown-menu popularity was classified as popular.
We found that @commercetools-uikit/dropdown-menu demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.