Skip to content

Menubar underlining a letter #3283

Closed Answered by Matthew-Boyd
Matthew-Boyd asked this question in PrimeVue
Discussion options

You must be logged in to vote

Add a passthrough for itemLabel:

<template>
  <Menubar 
    ref="menuRef" 
    :model="menuItems"
    :pt="{
      itemLabel: ({ context }) => ({
        innerHTML: renderMnemonic(context.item.label, context.item.mnemonic, showMnemonics)
      })
    }"
  />
</template>

<script setup>
const menuItems = ref([
  {
    label: 'File',
    mnemonic: "F",
    items: [
      { label: 'New', mnemonic: "N", command: () => newFile() },
      { label: 'Open', mnemonic: "O", command: () => openFile() }
    ]
  }
]);

const menuRef = ref(null);
const showMnemonics = ref(false);

const renderMnemonic = (label: any, mnemonic: any, show: any) => {
  if (!mnemonic || !show) return label;
  const index = …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Matthew-Boyd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant