Skip to main content

Dropdown

Ask AIView as Markdown
Copy a prompt to ask an AI assistant about this page.

Dropdown containers display a menu with additional items when users click on the trigger element, e.g. a dropdown button.

Dropdown - Code

Basic​

Open a dropdown at a pointer location (e.g. context menu)​

Since 6.0.0

Use showAt(x, y) with the viewport coordinates from the contextmenu event. The dropdown can also be positioned declaratively with its anchorPosition property (see the API below).

<div id="target">Right-click here</div>

<ix-dropdown id="context-menu" role="menu">
<ix-dropdown-item label="Open"></ix-dropdown-item>
<ix-dropdown-item label="Delete"></ix-dropdown-item>
</ix-dropdown>

<script>
const target = document.querySelector('#target');
const menu = document.querySelector('#context-menu');

target.addEventListener('contextmenu', (event) => {
event.preventDefault();
menu.showAt(event.clientX, event.clientY);
});
</script>

API for ix-dropdown​

Properties​

Methods​

Events​

Slot​

API for ix-dropdown-item​

Properties​

Slot​