To solve the issue of the dropdown menu items getting cut off by the table content, you can make the following changes to the code:
- Add a higher z-index value to the dropdown menu container to ensure it appears on top of other elements. Update the
MenuItemscomponent with thez-50class:
<MenuItems class="absolute z-50 right-0 mt-2 w-56 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none z-50">
- Adjust the positioning of the dropdown menu container to prevent it from being cut off by the table. Update the
MenuItemscomponent with thetop-12class:
<MenuItems class="absolute z-50 right-0 mt-2 w-56 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none z-50 top-12">
- If the dropdown menu still gets cut off, you can try adding a higher z-index value to the table container as well. Update the
tableelement with thez-10class:
<table class="min-w-full table-auto divide-y divide-gray-200 dark:divide-gray-700 z-10">
By applying these changes, the dropdown menu should appear on top of the table content and not get cut off.
Here is the updated code:
<table class="min-w-full table-auto divide-y divide-gray-200 dark:divide-gray-700 z-10">
<tbody>
<tr tabindex="0" class="focus:outline-none hover:bg-gray-100 h-16 border border-gray-100 rounded">
<td>
<Menu as="div" class="relative inline-block text-left">
<div>
<MenuButton class="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">
Options
<ChevronDownIcon class="-mr-1 h-5 w-5 text-gray-400" aria-hidden="true"/>
</MenuButton>
</div>
<transition enter-active-class="transition ease-out duration-100"
enter-from-class="transform opacity-0 scale-95"
enter-to-class="transform opacity-100 scale-100"
leave-active-class="transition ease-in duration-75"
leave-from-class="transform opacity-100 scale-100"
leave-to-class="transform opacity-0 scale-95">
<MenuItems class="absolute z-50 right-0 mt-2 w-56 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none z-50 top-12">
<div class="py-1">
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Edit</a>
</MenuItem>
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Duplicate</a>
</MenuItem>
</div>
<div class="py-1">
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Archive</a>
</MenuItem>
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Move</a>
</MenuItem>
</div>
<div class="py-1">
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Share</a>
</MenuItem>
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Add to favorites</a>
</MenuItem>
</div>
<div class="py-1">
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block px-4 py-2 text-sm']">Delete</a>
</MenuItem>
</div>
</MenuItems>
</transition>
</Menu>
</td>
</tr>
...
</tbody>
</table>
Please give it a try and let me know if it solves the issue.