How to use this component
The MenuPrimitive component renders an interactive element that triggers a custom event handler provided by the :toggle block (passed via hash by Ember). To comply with accessibility best practices, this element is usually a button or a component that renders a button.
When the content is disclosed, the container can be closed in various way; toggling via the button (click or enter/return), clicking outside of the content, or via the esc key.
Note: DisclosurePrimitive, another variant of this primitive, excludes the functionality to close the content panel by either clicking outside of the content, or via the esc key.
<Hds::MenuPrimitive>
<:toggle as |t|>
<button type="button" {{on "click" t.onClickToggle}}>Click me</button>
</:toggle>
<:content>
your content here
</:content>
</Hds::MenuPrimitive>
Content positioning
The :content block is not positioned in relation to the :toggle block. We recommend applying position: absolute to a wrapper around the content that is then passed to the :content block.
Component API
MenuPrimitive
<:toggle>
named block
[T].onClickToggle
function
[T].isOpen
boolean
isOpen.
<:content>
named block
[C].close
function
onClose
function
…attributes
...attributes.
4.10.0
In this version we replaced all MenuPrimitive instances with PopoverPrimitive. For this reason we now consider the MenuPrimitive deprecated and we plan to removed in a future major release.
How to migrate
Consider migrating the existing MenuPrimitive instances to PopoverPrimitive.