Skip to main content

Popup Menu

Popup Menu is used to create menus outside the main navigation, e.g. context menus. If used in a context where the nearest positined ancestor is in the shadow DOM (e.g. DuetCard) the popup menu may not be positioned correctly. This can be avoide by using a positioned wrapper element, e.g. div with position relative.

Examples #

Open in new window
<duet-button size="small" id="menu-toggle">toggle menu</duet-button>
<duet-popup-menu accessibleLabel="Sample action menu" id="sample-menu">
<duet-popup-menu-item leading-icon="category-pet">Some Action</duet-popup-menu-item>
<duet-popup-menu-item>Another Action With a Much Longer Label</duet-popup-menu-item>
<duet-popup-menu-item active trailing-icon="messaging-success">Active Action</duet-popup-menu-item>
<duet-popup-menu-item url="#" trailing-text="⌘ A">Actually a link</duet-popup-menu-item>
</duet-popup-menu>

<script>
(function(){
document.getElementById('menu-toggle').addEventListener('click', function(evt) {
const menu = document.getElementById('sample-menu');
menu.controller = evt.target;
menu.toggle();
});
}())
</script>
Open in new window
<duet-button size="small" id="menu-toggle">toggle menu</duet-button>
<duet-popup-menu controller="menu-toggle" accessibleLabel="Sample action menu" accessible-role="list" skip-teleport>
<duet-popup-menu-item leading-icon="category-pet" accessible-role="listitem">Some Action</duet-popup-menu-item>
<duet-popup-menu-item accessible-role="listitem">Another Action With a Much Longer Label</duet-popup-menu-item>
<duet-popup-menu-item active trailing-icon="messaging-success" accessible-role="listitem">Active Action</duet-popup-menu-item>
<duet-popup-menu-item url="#" trailing-text="⌘ A" accessible-role="listitem">Actually a link</duet-popup-menu-item>
</duet-popup-menu>
<duet-button size="small">next button</duet-button>
Open in new window
<duet-button size="small" id="menu-toggle">toggle menu</duet-button>
<duet-popup-menu controller="menu-toggle" accessibleLabel="Sample action menu" accessible-role="list" skip-teleport>
<span><duet-popup-menu-item leading-icon="category-pet" accessible-role="listitem">Some Action</duet-popup-menu-item></span>
<span><duet-popup-menu-item accessible-role="listitem">Another Action With a Much Longer Label</duet-popup-menu-item></span>
<span><duet-popup-menu-item active trailing-icon="messaging-success" accessible-role="listitem">Active Action</duet-popup-menu-item></span>
<span><duet-popup-menu-item url="#" trailing-text="⌘ A" accessible-role="listitem">Actually a link</duet-popup-menu-item></span>
</duet-popup-menu>
<duet-button size="small">next button</duet-button>

Properties #

Property Attribute Description Type Default
accessibleLabel accessible-label Adds accessible label for the menu that is only presented for users of assistive technologies. A popup menu should always have an accessible label that describes the popup's function. string undefined
accessibleRole accessible-role Accessible role. "list" | "menu" "menu"
controller controller Element controlling the opening and closing of the popup menu. HTMLElement & FocusableComponent & OpenerComponent | string undefined
crossAxisOffset cross-axis-offset Cross axis positioning offset of the popup menu relative to its controller. For "top" and "bottom" placements cross axis is horizontal, for "left" and "right" vertical. number 0
forcePlacement force-placement Force placement. boolean false
mainAxisOffset main-axis-offset Main axis positioning offset of the popup menu relative to its controller. For "top" and "bottom" placements main axis is vertical, for "left" and "right" horizontal. number 0
placement placement Placement of the popup menu relative to its controller. Possible values: "top", "bottom", "left" and "right", optionally combined with "-start" or "-end". "bottom" | "bottom-end" | "bottom-start" | "left" | "left-end" | "left-start" | "right" | "right-end" | "right-start" | "top" | "top-end" | "top-start" "bottom-start"
position position Position. "absolute" | "fixed" "absolute"
theme theme Theme. "" | "default" | "turva" ""

Events #

Event Description Type
duetToggle Emitted when the popup menu is opened or closed. CustomEvent<{ open: boolean; component: "duet-popup-menu"; }>

Methods #

hide() => Promise<void> #

Hide.

Returns #

Type: Promise<void>

isOpen() => Promise<boolean> #

isOpen.

Returns #

Type: Promise<boolean>

show() => Promise<void> #

Show.

Returns #

Type: Promise<void>

toggle() => Promise<void> #

Toggle.

Returns #

Type: Promise<void>


Usage #

This section includes guidelines for designers and developers about the usage of this component in different contexts.

When to use #

  • When you want to have a menu that pops up outside the main navigation.

When not to use #

  • If you are using Toolbar or Menubar.

Accessibility #

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. You can find additional information regarding accessibility of this component below.


Integration

For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.

Integration guidelines


Tutorials

Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:

Tutorials

Building Layouts

Tutorials

Using CLI Tools

Tutorials

Creating Custom Patterns

Tutorials

Server Side Rendering

Tutorials

Sharing Prototypes

Tutorials

Usage With Markdown


Troubleshooting

If you experience any issues while using a component, please head over to the Support page for more guidelines and help.