This is a navigation lib that generates a navigation menu from a list of MenuItem
objects. The menu supports infinite levels of nested items using hover cards.
- Infinite nested navigation using hover cards
- Customizable styles with Tailwind CSS
- Easy to use
import React from "react";
import NavigationMenu from "./src/index";
import { MenuItem } from "./src/types";
const items: MenuItem[] = [
{ id: "1", name: "Home", url: "/" },
{ id: "2", name: "About", url: "/about" },
{ id: "3", name: "Services", url: "/services", parent_id: "1" },
{ id: "4", name: "Contact", url: "/contact" },
];
function App() {
return <NavigationMenu items={items} />;
}
export default App;
The NavigationMenu
component accepts an optional options
prop to customize the behavior and appearance of the menu. The MenuOptions
interface defines the available options:
recursive
(boolean): Whether the menu should be recursive. Default istrue
.maxDepth
(number | null): The maximum depth of the menu. Default isnull
(no limit).ul
(string): Custom class for theul
element.ul_outer
(string): Custom class for the outerul
element.li
(string): Custom class for theli
element.li_outer
(string): Custom class for the outerli
element.li_parent
(string): Custom class for the parentli
element.a
(string): Custom class for thea
element.a_outer
(string): Custom class for the outera
element.a_parent
(string): Custom class for the parenta
element.