# `LedgerUI.Components.ContextMenu`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/context_menu.ex#L1)

A menu that opens under the pointer on a right click.

    <.context_menu id="file-menu">
      <div class="lu-panel">Right click here</div>
      <:item phx-click="rename" icon="edit" kbd="F2">Rename</:item>
      <:item phx-click="copy">Copy</:item>
      <:item phx-click="delete" tone="danger" divider icon="trash">Delete</:item>
    </.context_menu>

The hook `LedgerUI.ContextMenu` (`priv/static/ledger_ui/hooks/context_menu.js`) opens the menu
at the pointer (kept inside the window, in the top layer), moves the focus to the first item
and closes it on a click outside, `Escape`, a scroll and when an item is chosen. The arrows,
`Home`, `End` and letters move between the items.

Besides the README attrs the `:item` slot takes `icon` (a name) and `kbd` (a shortcut shown
as text).

# `context_menu`

## Attributes

* `id` (`:string`) (required)
* `label` (`:string`) - Accessible name of the menu. Defaults to `"Actions"`.
* `class` (`:any`) - Defaults to `nil`.
* `placement` (`:string`) - Where the menu sits against the pointer (`bottom-start`: below, from the pointer to the right). Defaults to `"bottom-start"`. Must be one of `"bottom-start"`, `"bottom-end"`, `"top-start"`, or `"top-end"`.
* Global attributes are accepted.
## Slots

* `inner_block` (required) - The area that answers to the right click.
* `trigger` - The area that answers to the right click, in place of the inner block (the vitrine's form).
* `item` - Accepts attributes:

  * `tone` (`:string`)
  * `divider` (`:boolean`)
  * `disabled` (`:boolean`)
  * `icon` (`:string`)
  * `kbd` (`:string`)
  * `phx-click` (`:any`)
  * `phx-value-id` (`:any`)
  * `phx-target` (`:any`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
