Dropdown menu
Dropdown-menu component allows you to create nested menus with menu-items
Use cases:
- Creating a menu for configuring options
Example
- Genesis
- React
- Angular
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,
},
];
}
Declaration
<rapid-dropdown-menu></rapid-dropdown-menu>
Usage
export function MyComponent() {
const setOfItems = [
{
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: () => console.log('Menu item 4 clicked'),
isDisabled: () => true,
},
];
return (
<CodeSection>
<rapid-dropdown-menu items={setOfItems}></rapid-dropdown-menu>
</CodeSection>
)
}
Declaration
<rapid-dropdown-menu></rapid-dropdown-menu>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'my-component',
template: `
<div class="code-section">
<rapid-dropdown-menu [items]="setOfItems"></rapid-dropdown-menu>
</div>
`,
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [FormsModule],
})
export class MyComponent {
setOfItems = [
{
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: () => console.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
Attribute | Type | Description | Example |
---|---|---|---|
auto-close | boolean | Controls if the dropdown automatically closes (Default: true) |
|
disable-button | boolean | Disables the dropdown button (Default: false) |
|
name | string | The name of the dropdown menu (Default: 'Dropdown Menu') |
|
open | boolean | Controls if the dropdown is open (Default: false) |
|
buttonAppearance | string | Sets the appearance style of the button (Default: none) |
|
Properties
Property | Type | Description | Example |
---|---|---|---|
items | DropdownMenuItem[] | Configure the items to be in the dropdown menu. |
|
Slots
Slot | Description |
---|---|
Default | The text which appears on the root dropdown menu button. |
Parts
Part | Description |
---|---|
actions-container | The main container element which wraps up the button and the dropdown menu. |
actions-opener | The button which opens the dropdown. |
actions-menu | The dropdown menu. |
Events fired
This component doesn't fire any events.
Events listened to
This component doesn't listen to any events.