Menu
A hand-drawn style menu component for displaying navigation items and actions with sections, icons, and interactive selection states.
Menu
The Menu component provides a versatile solution for displaying navigation items and actions. It features Faiz UI's signature hand-drawn aesthetic while offering rich functionality including sections, icons, descriptions, and selection states.
Usage
Basic menu with simple items.
With Icons
Add icons to menu items for better visual context.
With Descriptions
Add descriptions to provide additional context for menu items.
With Sections
Organize menu items into logical sections with titles and dividers.
With Badges
Add badges or indicators to menu items to show notifications, status, or labels.
As Links
Menu items can be rendered as anchor tags by providing an href prop, making them perfect for navigation menus.
Colors
Choose from various color themes to match your design.
Variants
Different visual styles for the menu container.
Sizes
Menu supports three different sizes.
Disabled Items
Disable specific menu items to prevent interaction.
Selected State
Highlight the currently selected menu item.
Interactive Example
A fully interactive menu with selection state and feedback.
Select an item from the menu
Implementation Notes
- Menu items are fully keyboard accessible with proper ARIA attributes and keyboard navigation (Enter/Space to activate)
- The component uses semantic HTML with
role="menu"androle="menuitem" - Selected items are automatically highlighted when using
selectedKeyprop - Disabled items prevent both click events and keyboard navigation
- Icons can be placed at the start or end of menu items
- Badges can be added to show notifications, status indicators, or labels
- Menu items can be rendered as links by providing an
hrefprop - External links automatically get
rel="noopener noreferrer"whentarget="_blank"is used - Sections help organize items into logical groups with optional titles
- The menu inherits the hand-drawn aesthetic from the Faiz UI design system
Props
Menu Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "solid" | "bordered" | "light" | "flat" | "solid" | The visual style variant of the menu |
color | "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "default" | The color theme of the menu |
size | "sm" | "md" | "lg" | "md" | The size of the menu and its items |
selectedKey | string | - | The key of the currently selected item |
onSelect | (key: string) => void | - | Callback fired when a menu item is selected |
closeOnSelect | boolean | false | Whether to close the menu when an item is selected (useful with dropdown menus) |
customStyles | string | - | Additional CSS classes for custom styling |
className | string | - | Additional CSS classes |
MenuItem Props
| Prop | Type | Default | Description |
|---|---|---|---|
itemKey | string | - | Unique key for the item (required for selection tracking) |
isDisabled | boolean | false | Whether the menu item is disabled |
isSelected | boolean | false | Whether the menu item is selected (controlled) |
startIcon | ReactNode | - | Icon to display at the start of the item |
endIcon | ReactNode | - | Icon to display at the end of the item |
description | string | - | Additional description text below the main content |
badge | ReactNode | - | Badge or indicator to display (e.g., notification count, status label) |
badgeColor | "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "default" | Color variant for the badge |
href | string | - | URL to navigate to (renders item as <a> tag) |
target | string | - | Target attribute for link (e.g., "_blank") |
rel | string | - | Rel attribute for link (auto-set to "noopener noreferrer" when target is "_blank") |
onClick | (e: React.MouseEvent) => void | - | Custom click handler |
as | React.ElementType | "div" | The HTML element to render as (defaults to "a" when href is provided) |
className | string | - | Additional CSS classes |
MenuSection Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | Title text for the section |
as | React.ElementType | "div" | The HTML element to render as |
className | string | - | Additional CSS classes |
MenuDivider Props
| Prop | Type | Default | Description |
|---|---|---|---|
as | React.ElementType | "hr" | The HTML element to render as |
className | string | - | Additional CSS classes |