Do not use built-in or reserved HTML elements with Vue, TailwindUI and Headless UI

I’m trying to add the TailwindUI / Headless UI Menu (dropdown) to Vue and am getting two errors in the console:

Do not use built-in or reserved HTML elements as component id: menu

and

Error: < MenuButton /> is missing a parent < Menu /> component

I’m Using Vue 3 within a Laravel 8 app, here’s what app.js looks like:

import { Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/vue";
const app = createApp({
  ...
});
app.component('menu', Menu);
app.component('menubutton', MenuButton);
app.component('menuitems', MenuItems);
app.component('menuitem', MenuItem);
app.mount("#app");

And here’s a minimal example for the view:
<Menu>
  <MenuButton>More</MenuButton>
  <MenuItems>
    <MenuItem v-slot="{ active }">
      <a :class='{ "bg-blue-500": active }' href="/test">
        Test
      </a>
    </MenuItem>
  </MenuItems>
</Menu>

I’ve tried everything that I can think of and am lost! Any ideas?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Do not use <Menu>-element as it is a built-in HTML element.

Just rename to something like CustomMenu

import { Menu as CustomMenu, ... } from ...
app.component('menu', CustomMenu);
<CustomMenu>
...


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x