Skip to main content

Dropdown menu

Dropdown-menu component allows you to create nested menus with menu-items

Use cases:

  • Creating a menu for configuring options

Example

Declaration

<rapid-dropdown-menu></rapid-dropdown-menu>

Usage

import { DropdownMenuItem } from '@genesislcap/web-core';

@customElement({
name: 'my-element',
template: html`
<rapid-dropdown-menu :items=${(x) => x.setOfItems}></rapid-dropdown-menu>
`,
})
export class MyElement extends GenesisElement {
setOfItems: DropdownMenuItem[] = [
{
name: 'Menu item 1',
callback: () => alert('Menu item 1 clicked'),
icon: {
name: 'glasses',
},
},
{
name: 'Menu item 3',
callback: () => alert('Menu item 3 clicked'),
submenu: [
{
name: 'Menu item 5',
callback: () => alert('Menu item 5 clicked'),
color: 'red',
icon: {
name: 'address-card',
},
},
]
},
{
name: 'Menu item 4',
callback: () => logger.debug('Menu item 4 clicked'),
isDisabled: () => true,
},
];
}

API

Configuration Type

The configuration of the dropdown menu is described by this typescript type.

export type DropdownMenuItem = {
name: string;
icon?: {
variant?: IconStyle;
name: string;
size?: FaSize;
};
color?: string;
submenu?: DropdownMenuItem[];
callback?: (params?: any) => void | any;
isDisabled?: (params?: any) => boolean;
};

Attributes

AttributeTypeDescriptionExample
auto-closebooleanControls if the dropdown automatically closes (Default: true)
<rapid-dropdown-menu auto-close>
disable-buttonbooleanDisables the dropdown button (Default: false)
<rapid-dropdown-menu disable-button>
namestringThe name of the dropdown menu (Default: 'Dropdown Menu')
<rapid-dropdown-menu name="Dropdown Menu">
openbooleanControls if the dropdown is open (Default: false)
<rapid-dropdown-menu open>
buttonAppearancestringSets the appearance style of the button (Default: none)
<rapid-dropdown-menu buttonAppearance="primary">

Properties

PropertyTypeDescriptionExample
itemsDropdownMenuItem[]Configure the items to be in the dropdown menu.
<rapid-dropdown-menu :items=${x => x.menuItems}>

Slots

SlotDescription
DefaultThe text which appears on the root dropdown menu button.

Parts

PartDescription
actions-containerThe main container element which wraps up the button and the dropdown menu.
actions-openerThe button which opens the dropdown.
actions-menuThe dropdown menu.

Events fired

This component doesn't fire any events.

Events listened to

This component doesn't listen to any events.