Default Menu
To add a basic menu with default styling use the
menu
and
menu-default
classes.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-36 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-title">
Menu link 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-title">
Menu link 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-title">
Menu link 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-title">
Menu link 4
</span>
</a>
</div>
</div>
Advanced Item
This example demonstrates an advanced menu items with icons, badges, and titles.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 3
</span>
<span class="menu-badge">
<span class="badge badge-sm badge-outline badge-pill badge-primary">
New
</span>
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Menu item 4
</span>
</a>
</div>
</div>
Separator
To separate menu item groups
menu-separator
class.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-separator">
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Menu item 4
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Menu item 5
</span>
</a>
</div>
<div class="menu-separator">
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-element-11">
</i>
</span>
<span class="menu-title">
Menu item 6
</span>
</a>
</div>
</div>
Horizontal
This example demonstrates a horizontal menu usage.
<div class="menu menu-default flex flex-wrap justify-center gap-2.5 border rounded-lg py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 3
</span>
<span class="menu-badge">
<span class="badge badge-sm badge-outline badge-pill badge-danger">
New
</span>
</span>
</a>
</div>
</div>
States
Tailwind CSS Menu component supports
hover
,
active
,
show
,
here
and
focus
states.
Explore detailed information about each state by referring to the
Tailwind CSS Menu Classes
guide.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Default/Hover states
</span>
</a>
</div>
<div class="menu-item active">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Active state
</span>
</a>
</div>
<div class="menu-item show">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Show state
</span>
<span class="menu-badge" data-tooltip="true">
<i class="ki-outline ki-information-2">
</i>
<span class="tooltip">
Has shown submenu
</span>
</span>
</a>
</div>
<div class="menu-item here">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Here state
</span>
<span class="menu-badge" data-tooltip="true">
<i class="ki-outline ki-information-2">
</i>
<span class="tooltip">
Has active child in submenu
</span>
</span>
</a>
</div>
<div class="menu-item disabled">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Disabled state
</span>
</a>
</div>
</div>
Accordion - Basic
Utilize the Tailwind CSS KTMenu component to enable accordion-style submenu support for your menus.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-user-square">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-calendar">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-timer">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-calendar-2">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-question">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-user">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Accordion - Default Open
Use
active
and
show
classes on an menu item to display a specific submenu by default.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item show" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Accordion - Expand All
Use
data-menu-accordion-expand-all="true"
attribute to keep all submenus visible
at all times despite toggling other.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2" data-menu="true" data-menu-accordion-expand-all="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item show" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item show" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Accordion - Arrow Icon
Enhance your accordion submenu with custom toggle icons.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down menu-item-show:hidden">
</i>
<i class="ki-outline ki-up hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down menu-item-show:hidden">
</i>
<i class="ki-outline ki-up hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Accordion - Multi-level
Tailwind CSS KTMenu provides robust support for multi-level accordion submenus,
allowing you to create deeply nested navigation structures with ease and flexibility.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-60 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Nested submenu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Nested submenu 5
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<span class="w-2 h-1 bg-gray-300 rounded-full">
</span>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<span class="w-2 h-1 bg-gray-300 rounded-full">
</span>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<span class="w-2 h-1 bg-gray-300 rounded-full">
</span>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Accordion - Reverse
Utilize the Tailwind CSS
flex-col-reverse
class in conjunction with the
menu-item
class to showcase the submenu accordion from the top,
deviating from its default behavior which is to expand from the bottom.
Apply the
menu-no-indent
class to the
menu-accordion
element to reset the submenu indentation.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-48 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 3
</span>
</a>
</div>
<div class="menu-item flex-col-reverse" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link !py-1" href="#">
<span class="menu-icon w-4">
</span>
<span class="menu-title !text-gray-500">
<span class="hidden menu-item-show:block">
Show less
</span>
<span class="block menu-item-show:hidden">
Show 3 more
</span>
</span>
</a>
<div class="menu-accordion menu-no-indent">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-bitcoin">
</i>
</span>
<span class="menu-title">
Menu item 4
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Menu item 5
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Menu item 6
</span>
</a>
</div>
</div>
</div>
</div>
Accordion - Dropdown
Integrate a Tailwind CSS Menu accordion submenu with its dropdown submenu
to create a hierarchical navigation structure that is user-friendly and visually organized.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-60 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Accordion submenu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-user-square">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-information-5">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-file">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Dropdown submenu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-user-square">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-information-5">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-file">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-files-tablet">
</i>
</span>
<span class="menu-title">
Menu item 3
</span>
</a>
</div>
</div>
Dropdown - Basic
Utilize the Tailwind CSS KTMenu component to enable dropdown submenu support for your menus.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-48 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Horizontal
This example showcases a horizontal Tailwind CSS Menu with dropdown submenus,
offering a clear and organized layout for navigation.
<div class="menu menu-default flex justify-center border rounded-lg gap-1 p-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Button
This example demonstrates a toggle button for a Tailwind CSS Menu with a dropdown submenu,
providing a user-friendly way to navigate through the menu options.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
<span class="menu-title">
Button Menu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Multi-level
Tailwind CSS KTMenu provides robust support for multi-level dropdown submenus,
allowing you to create deeply nested navigation structures with ease and flexibility.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-48 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - With Modal
Incorporate a Tailwind CSS Menu within a Tailwind CSS Modal component
to enhance user interaction and create a seamless experience,
especially for advanced use cases.
<button class="btn btn-primary" data-modal-toggle="#modal_1">
Show Modal
</button>
<div class="modal max-w-[600px] top-[10%]" data-modal="true" id="modal_1">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">
Modal Title
</h3>
<button class="btn btn-xs btn-icon btn-icon-xl btn-light" data-modal-dismiss="true">
<i class="ki-outline ki-cross">
</i>
</button>
</div>
<div class="modal-body flex items-center justify-center min-h-[400px]">
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Button Menu
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Dropdown - With Tooltip
Combine a Tailwind CSS Menu with a Tailwind CSS Tooltip to enhance user navigation and provide additional contextual information,
resulting in a more interactive and intuitive user experience.
Hey, a delightful tooltip is here!
Hey, this is a finely polished tooltip example.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Button Menu
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" data-tooltip="#tooltip_1" data-tooltip-placement='"right"' href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" data-tooltip="#tooltip_2" data-tooltip-placement='"right"' href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
<div class="tooltip" id="tooltip_1">
Hey, a delightful tooltip is here!
</div>
<div class="hidden rounded-xl shadow-default p-3 bg-light border border-gray-200 text-gray-600 text-xs font-normal" id="tooltip_2">
Hey, this is a finely polished tooltip example.
</div>
Dropdown - Accordion
Integrate a Tailwind CSS Menu dropdown submenu with its accordion-style submenu
to create a hierarchical navigation structure that is user-friendly and visually organized.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Button Menu
</button>
<div class="menu-dropdown w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Nested submenu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Scrollable
Integrate the
Tailwind CSS Scrollable
component to efficiently manage a lengthy list of menu items, ensuring a smooth and user-friendly navigation experience.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
<span class="menu-title">
Button Menu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</button>
<div class="menu-dropdown w-48 py-2">
<div class="scrollable-y h-[300px]">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
</div>
Dropdown - Permanent
Apply the
data-menu-item-permanent="true"
attribute to a menu item to keep
its dropdown submenu open, ensuring it stays visible after being clicked.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-permanent="true" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="click">
<button class="menu-toggle btn btn-light">
<span class="menu-title">
Button Menu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="javascript:;">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="javascript:;">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="javascript:;">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Dismiss
Apply the
data-menu-dismiss="true"
attribute to any element within the Tailwind CSS KTMenu Sub-menu element
to ensure the dropdown sub-menu closes upon click.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="click">
<button class="menu-toggle btn btn-light">
<span class="menu-title">
Button Menu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item" data-menu-dismiss="true">
<a class="menu-link" href="javascript:;">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-dismiss="true">
<a class="menu-link" href="javascript:;">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-dismiss="true">
<a class="menu-link" href="javascript:;">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Placement
Use
data-menu-item-placement
attribute with
[top|bottom|left|right]-start
,
[top|bottom|left|right]
,
[top|bottom|left|right]-end
placement options
for the Tailwind CSS Menu to ensure that the dropdown appears relative to the toggle element in the desired position.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="top-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Top Start
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Bottom Start
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="left-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Left Start
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Right Start
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Trigger
Use the
data-menu-item-trigger
attribute with the
hover
and
click
options to enable the submenu to be triggered either by user click or hover actions.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
Hover Trigger
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="click">
<button class="menu-toggle btn btn-light">
Click Trigger
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Offset
Use
data-menu-item-offset="10px, 10px"
attribute
to add distance between the menu toggle and dropdown element.
The pair of
x,y
value in pixel translates the floating element along the x and y axes.
<div class="menu menu-default" data-menu="true">
<div class="menu-item" data-menu-item-offset="10px, 10px" data-menu-item-placement="bottom-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<button class="menu-toggle btn btn-light">
<span class="menu-title">
Button Menu
</span>
<span class="menu-arrow">
<i class="ki-outline ki-down">
</i>
</span>
</button>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Dropdown - Overflow
Utilize the
data-menu-item-overflow="true"
attribute
to ensure that dropdown submenus are displayed within a scrollable menu container,
offering a seamless user experience even with a large number of menu items.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-48 py-2 scrollable h-[300px]" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-overflow="true" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown menu-default w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown menu-default w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-user-square">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-tablet-ok">
</i>
</span>
<span class="menu-title">
Menu item 3
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-chart-simple">
</i>
</span>
<span class="menu-title">
Menu item 4
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 5
</span>
</a>
</div>
<div class="menu-item" data-menu-item-overflow="true" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown menu-default w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-chart">
</i>
</span>
<span class="menu-title">
Menu item 6
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-magnifier">
</i>
</span>
<span class="menu-title">
Menu item 7
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-trash">
</i>
</span>
<span class="menu-title">
Menu item 8
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-information">
</i>
</span>
<span class="menu-title">
Menu item 9
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-wrench">
</i>
</span>
<span class="menu-title">
Menu item 10
</span>
</a>
</div>
</div>
Dropdown - Responsive
Set the
data-menu-item-toggle
attribute value to
accordion|lg:dropdown
to ensure that
Tailwind CSS Menu submenus are displayed appropriately across different devices,
with an accordion-style display on smaller screens and a dropdown display on larger screens.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="accordion|lg:dropdown" data-menu-item-trigger="click|lg:hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow hidden lg:flex">
<i class="ki-outline ki-right">
</i>
</span>
<span class="menu-arrow lg:hidden">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-dropdown w-full lg:w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="accordion|lg:dropdown" data-menu-item-trigger="click|lg:hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow hidden lg:flex">
<i class="ki-outline ki-right">
</i>
</span>
<span class="menu-arrow lg:hidden">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-dropdown w-full lg:w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="accordion|lg:dropdown" data-menu-item-trigger="click|lg:hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu 2
</span>
<span class="menu-arrow hidden lg:flex">
<i class="ki-outline ki-right">
</i>
</span>
<span class="menu-arrow lg:hidden">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-dropdown w-full lg:w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
</div>
Source Code
The following source files manage the JavaScript behavior and CSS styles of the Tailwind CSS Menu component.
Upon building the assets using
Webpack Build Tools
,
these files are compiled and added into the
dist/assets/css/styles.css
and
dist/assets/js/core.bundle.js
bundles, making them available globally across all pages.
File | Description |
---|---|
src/core/components/menu/menu.ts
|
The TypeScript source file that manages the JavaScript behavior of the Tailwind CSS Menu component. |
src/core/plugins/components/menu.js
|
The Tailwind CSS compatible plugin written in PostCSS for applying CSS styles to the Tailwind CSS Menu component. |
HTML Markup
The following markup outlines the core structure of the Tailwind CSS Menu component.
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
<span class="menu-badge">
<span class="badge badge-circle badge-success size-5">
5
</span>
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
</div>
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-48 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-placement="right-start" data-menu-item-toggle="dropdown" data-menu-item-trigger="hover">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-right">
</i>
</span>
</a>
<div class="menu-dropdown w-48 py-2">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-message-programming">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-icon">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
</div>
<div class="menu menu-default flex flex-col border rounded-lg w-full max-w-56 py-2" data-menu="true">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-badge">
</i>
</span>
<span class="menu-title">
Menu item 1
</span>
</a>
</div>
<div class="menu-item" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-profile-circle">
</i>
</span>
<span class="menu-title">
Submenu 1
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
<div class="menu-accordion">
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-user-square">
</i>
</span>
<span class="menu-title">
Submenu item 1
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-calendar">
</i>
</span>
<span class="menu-title">
Submenu item 2
</span>
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-timer">
</i>
</span>
<span class="menu-title">
Submenu item 3
</span>
</a>
</div>
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-setting-2">
</i>
</span>
<span class="menu-title">
Menu item 2
</span>
</a>
</div>
</div>
Classes
This table details the custom CSS classes used for styling the Tailwind CSS Menu component.
Class | Description |
---|---|
menu
|
Root class of Tailwind CSS Menu component. |
menu-default
|
Applies default styling for Tailwind CSS Menu component. |
menu-accordion
|
Provides accordion-style interaction for submenu items. |
menu-no-indent
|
Removes the indentation for the accordion submenu items. |
menu-dropdown
|
Enables dropdown functionality for submenu items. |
menu-separator
|
Adds a separator line between menu items for visual distinction. |
menu-item
|
Represents a single item within the menu. |
menu-link
|
Defines a link within a menu item, typically navigable. |
menu-arrow
|
Indicates the presence of a submenu or collapsible section. |
menu-title
|
Specifies the title for the menu item. |
menu-icon
|
Used for adding an icon to the menu link, enhancing visual identification. |
menu-badge
|
Displays a badge, like a notification count, next to a menu link. |
active
|
Marks the menu item as active or currently selected. |
here
|
Indicates the current location within the menu hierarchy, used on a menu item. |
show
|
Used to reveal a submenu or dropdown for a menu item, typically in a dynamic or responsive layout. |
focus
|
Applies focus styling to the menu item, usually for accessibility purposes. |
disabled
|
Disables a menu item, making it non-interactive and visually distinct. |
Variants
Utilize the following Tailwind CSS Menu variants to manage the appearance of the menu items and their child elements.
For more information, refer to the
Tailwind CSS Variant documentation
.
Class | Description |
---|---|
menu-item-active:
|
Applies styles when the menu item is active or currently selected. |
menu-item-hover:
|
Applies styles when the mouse pointer hovers over the menu item. |
menu-item-here:
|
Designates the menu item as the current location within the menu hierarchy. |
menu-item-show:
|
Controls the display of submenu items, typically used to show them on demand. |
menu-item-focus:
|
Applies styles when the menu item gains focus, usually through keyboard navigation. |
<div class="menu-item active" data-menu-item-toggle="accordion" data-menu-item-trigger="click">
<a class="menu-link" href="#">
<span class="menu-icon">
<i class="ki-outline ki-coffee">
</i>
</span>
<span class="menu-title menu-item-active:text-success menu-item-hover:text-primary">
Menu title
</span>
<span class="menu-arrow">
<i class="ki-outline ki-plus menu-item-show:hidden">
</i>
<i class="ki-outline ki-minus hidden menu-item-show:block">
</i>
</span>
</a>
</div>
Data Attribute Initialization
Auto-initialize all KTMenu instances on page load by adding the
data-menu="true"
attribute to your menu element.
This triggers on the fly initialization by the KTMenu JavaScript component.
<div class="menu menu-default" data-menu="true" id="my_menu">
...
</div>
These attributes allow you to set options for the KTMenu component during initialization.
The values you provide as strings are automatically converted to the appropriate
KTMenu Options
.
HTML Attribute | Type | Default | Description |
---|---|---|---|
data-menu
|
boolean
|
true
|
Used to auto-initialize KTMenu instances on page load. Alternatively, you can remove it and perform initialization using JavaScript. |
data-menu-dismiss
|
boolean
|
true
|
Apply to any element within KTMenu Sub-menu instance to ensure the dropdown sub-menu closes upon click. |
data-menu-dropdown-zindex
|
number
|
105
|
Sets the z-index for the dropdown menu to ensure it stacks above or below other elements as needed. |
data-menu-dropdown-hover-timeout
|
number
|
200
|
Specifies the delay in milliseconds before the dropdown menu opens or closes when hovered. |
data-menu-accordion-expand-all
|
boolean
|
false
|
Determines whether multiple submenu items in the accordion can be expanded simultaneously. |
data-menu-item-toggle
|
enum
"accordion" | "dropdown"
|
"accordion"
|
Defines the toggle behavior for menu items; can be set to use accordion or dropdown mechanics. |
data-menu-item-trigger
|
enum
"click" | "hover"
|
"click"
|
Specifies the trigger action for opening submenu items, either on click or hover. |
data-menu-item-offset
|
string
|
"0, 5px"
|
Sets a distance(the x and y axes) between the menu item toggle and dropdown submenu element. |
data-menu-item-offset-rtl
|
string
|
"0, 5px"
|
Sets a distance(the x and y axes) between the menu item toggle and dropdown submenu element for RTL languages. |
data-menu-item-permanent
|
boolean
|
false
|
Used to configure a menu item in such a way that its dropdown submenu remains open after being clicked. |
data-menu-item-placement
|
enum
"left-start" | "left" | "left-end" |
"right-start" | "right" | "right-end" |
"top-start" | "top" | "top-end" |
"bottom-start" | "bottom" | "bottom-end"
|
- | Determines the position of the submenu in relation to the menu item, with options for alignment and orientation. |
data-menu-item-placement-rtl
|
enum
"left-start" | "left" | "left-end" |
"right-start" | "right" | "right-end" |
"top-start" | "top" | "top-end" |
"bottom-start" | "bottom" | "bottom-end"
|
- | Determines the position of the submenu for RTL languages, in relation to the menu item, with options for alignment and orientation. |
JavaScript Initialization
To initialize a new menu component, pass the corresponding DOM element and configuration options to the KTMenu class constructor.
const menuEl = document.querySelector('#my_menu');
const options = {
dropdownZindex: 105,
dropdownHoverTimeout: 300,
accordionExpandAll: true
};
const menu = new KTMenu(menuEl, options);
<div class="menu menu-default" data-menu="false" id="my_menu">
<!-- Refer to the Menu HTML Markup above -->
</div>
To initialize the menu with JavaScript, use
data-menu="false"
attribute instead.
This prevents automatic initialization on page load.
Options
This table outlines the configuration options for initialization of Tailwind CSS Menu instances, using the KTMenu JavaScript component.
Option | Type | Default | Description |
---|---|---|---|
dropdownZindex
|
number
|
105
|
Sets the z-index for the dropdown menu to ensure it stacks above or below other elements as needed. |
dropdownHoverTimeout
|
number
|
200
|
Specifies the delay in milliseconds before the dropdown menu opens or closes when hovered. |
accordionExpandAll
|
boolean
|
false
|
Determines whether multiple submenu items in the accordion can be expanded simultaneously. |
Utilities
Manage and interact with KTMenu instances using these static methods of
KTMenu
class.
Method | Description |
---|---|
init()
|
Automatically initializes KTMenu object for all elements with the
data-menu="true"
attribute on page load.
|
createInstances()
|
Allows to create KTMenu instances for all elements that have been dynamically added to the DOM but haven't been activated yet. |
getInstance(element)
|
Returns the
KTMenu
object associated with the given DOM element
element
.
|
getOrCreateInstance(element)
|
Returns the existing
KTMenu
object for the provided DOM element
element
, or creates a new instance if none exists, then returns the same.
|
// Initialize all menus
KTMenu.init()
// Initialzie pending menus
KTMenu.createInstances();
// Get menu object
const menuEl = document.querySelector('#my_menu');
const menu = KTMenu.getInstance(menuEl);
<div class="menu menu-default" data-menu="true" id="my_menu">
...
</div>
Methods
Use KTMenu component's API methods to programmatically control its behavior.
Method | Description |
---|---|
new KTMenu(element, options)
|
Creates an object instance of KTMenu class for the given DOM
element
and configuration
options
.
|
show(itemElement)
|
Shows submenu of menu item associated with
itemElement
DOM element.
|
hide(itemElement)
|
Hides submenu of menu item associated with
itemElement
DOM element.
|
toggle(itemElement)
|
Toggles the visibility of submenu for the menu item associated with
itemElement
DOM element.
|
reset(itemElement)
|
Resets the state of the menu item and its submenu associated with
itemElement
DOM element to its default state.
|
getItemTriggerMode(itemElement)
|
Gets the trigger mode (click or hover) of the menu item associated with
itemElement
DOM element.
|
getItemToggleMode(itemElement)
|
Retrieves the toggle mode (accordion or dropdown) of the menu item associated with
itemElement
DOM element.
|
setActiveLink(linkElement)
|
Sets the specified
linkElement
as the active link in the menu.
|
getLinkByAttribute(linkElement)
|
Finds and returns a menu link that matches the specified attribute of
linkElement
.
|
getItemLinkElement(linkElement)
|
Gets the link element within the menu item associated with the specified
linkElement
.
|
getItemElement(linkElement)
|
Retrieves the menu item element associated with the specified
linkElement
.
|
getItemSubElement(linkElement)
|
Obtains the submenu element of the menu item associated with the specified
linkElement
.
|
getItemParentElements(linkElement)
|
Gets all parent elements of the menu item associated with the specified
linkElement
.
|
isItemSubShown(linkElement)
|
Checks if the submenu of the menu item associated with the specified
linkElement
is currently shown.
|
isItemParentShown(linkElement)
|
Determines if the parent item of the menu item associated with the specified
linkElement
is shown.
|
isItemDropdownPermanent(linkElement)
|
Checks if the dropdown of the menu item associated with the specified
linkElement
is set to permanent.
|
hideAccordions(itemElement)
|
Hides all accordion submenus of the menu item associated with
itemElement
DOM element.
|
disable()
|
Disables the menu submenu toggle functionality. |
update()
|
Updates and re-enables the menu submenu toggle functionality if it was previously disabled. |
getOption(name)
|
Retrieves the value of a configuration option by
name
parameter from a KTMenu instance.
|
getElement()
|
Retrieves the DOM element linked to a specific KTMenu instance. |
on(eventName, handler)
|
Allows attaching event listeners to the KTMenu custom events using the
eventName
and
eventId
string parameters. These events enable programmatic interaction based on user actions or
internal state changes of KTMenu. The function returns
string
as a unique identifier for the registered listener, allowing you to remove it later if needed.
|
off(eventName, eventId)
|
Removes an event listener for the
eventName
and
eventId
parameters attached with the
on
method.
|
dispose()
|
Removes the KTMenu instance from an element, including any associated data stored on the DOM element. |
const menuEl = document.querySelector('#my_menu');
const menuItemEl = document.querySelector('#my_menu_item_1');
const menu = KTMenu.getInstance(menuEl);
menu.show(menuItemEl);
menu.hide(menuItemEl);
<div class="menu menu-default" data-menu="true" id="my_menu">
...
</div>
Events
KTMenu
custom events allows you to register callback functions(event listeners)
that will be invoked automatically whenever specific custom events are triggered within the component.
Event | Description |
---|---|
link.click
|
Fires before a menu link is clicked and the action is processed. |
link.clicked
|
Fires after a menu link is clicked and the action is processed. |
dropdown.show
|
Triggers before a dropdown menu is shown. |
dropdown.shown
|
Triggers after a dropdown menu is fully displayed. |
dropdown.hide
|
Fires before a dropdown menu starts the hiding process. |
dropdown.hidden
|
Fires after a dropdown menu is completely hidden. |
accordion.show
|
Triggers before an accordion menu item expands. |
accordion.shown
|
Triggers after an accordion menu item has fully expanded. |
accordion.hide
|
Fires before an accordion menu item starts to collapse. |
accordion.hidden
|
Fires after an accordion menu item has fully collapsed. |
const menuEl = document.querySelector('#my_menu');
const menu = KTMenu.getInstance(menuEl);
menu.on('dropdown.show', () => {
console.log('dropdown show event');
});
menu.on('dropdown.shown', () => {
console.log('dropdown shown event');
});
menu.on('dropdown.hide', (detail) => {
detail.cancel = true;
console.log('dropdown hide action canceled');
});