WlContextMenu

Pointer and keyboard context menu with nested and checked items.
Components / Navigation v1.0.0-rc.1

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

ariaLabel

Accessible name when an external label is not referenced.

Disable user interaction with this component.

Enable motion locally, with application defaults and reduced-motion preferences respected.

Props items, placement, align, ariaLabelledby, pt, menuPt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

· Compact header: false

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlCard, WlContextMenu, type WlMenuItem } from "legato-ui";
import { computed, ref } from "vue";

const selection = ref("");
const compact = ref(false);
const items = computed<WlMenuItem[]>(() => [
  { label: "Edit", icon: "edit", command: () => { selection.value = "Editing"; } },
  { label: "View", items: [
    { label: "Compact header", type: "checkbox", checked: compact.value, onCheckedChange: (checked) => { compact.value = checked; } }
  ] },
  { label: "Unavailable", disabled: true },
  { separator: true },
  { label: "Delete", icon: "trash", danger: true, command: () => { selection.value = "Deletion"; } }
]);
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlContextMenu
      :items="items"
      aria-label="Material actions"
      data-context-example
      
    >
      <WlCard padding="md"><p>{{ "Material" }} · Shift+F10</p></WlCard>
    </WlContextMenu>
    <p role="status" class="wl-text-small">{{ selection }} · {{ "Compact header" }}: {{ compact }}</p>
  </div>
</template>

Context actions with nested choices

Pointer and keyboard context menu with nested and checked items.

· Compact header: false

Vue SFC · additional example
<script setup lang="ts">
import { WlCard, WlContextMenu, type WlMenuItem } from "legato-ui";
import { computed, ref } from "vue";

const selection = ref("");
const compact = ref(false);
const items = computed<WlMenuItem[]>(() => [
  { label: "Edit", icon: "edit", command: () => { selection.value = "Editing"; } },
  { label: "View", items: [
    { label: "Compact header", type: "checkbox", checked: compact.value, onCheckedChange: (checked) => { compact.value = checked; } }
  ] },
  { label: "Unavailable", disabled: true },
  { separator: true },
  { label: "Delete", icon: "trash", danger: true, command: () => { selection.value = "Deletion"; } }
]);
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlContextMenu :items="items" aria-label="Material actions">
      <WlCard padding="md"><p>{{ "Material" }} · Shift+F10</p></WlCard>
    </WlContextMenu>
    <p role="status" class="wl-text-small">{{ selection }} · {{ "Compact header" }}: {{ compact }}</p>
  </div>
</template>