We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Menu Component

The Menu component creates interactive selection interfaces with smooth transitions and accessibility features built-in. Perfect for navigation menus, tab interfaces, and content switching scenarios.

  • Check Circle

    State Management: Automatic handling of selection states

  • Check Circle

    Event Handling: Built-in change events and callbacks

  • Check Circle

    Accessibility: ARIA support and keyboard navigation

  • Check Circle

    Customizable: Flexible styling and configuration options

Create a simple menu with a list of options:

<Menu
name="theme"
items={['Light', 'Dark', 'System']}
defaultItem="System"
/>

The Menu component includes a MenuItem component for managing content visibility:

Product Details

View detailed information about the product.

Settings Panel

Configure your preferences and options.

<Menu name="tabs" items={['Details', 'Settings']} defaultItem="Details" />
<MenuItem name="tabs" itemName="Details">
<h3>Product Details</h3>
<p>View detailed information about the product.</p>
</MenuItem>
<MenuItem name="tabs" itemName="Settings">
<h3>Settings Panel</h3>
<p>Configure your preferences and options.</p>
</MenuItem>

The Menu component emits a menu-change event when selection changes:

Waiting for events to be emitted… (Click on the menu to see the events)
// Listen for menu changes
const menu = document.querySelector('menu-wrapper');
menu.addEventListener('menu-change', (event) => {
const { menuName, itemName } = event.detail;
console.log(`Menu: ${menuName}, Selected: ${itemName}`);
});
Required Props
Menu Props Extends <div> HTMLElement
Prop Type Default Description
name string - Unique identifier for the menu
items string[] - Array of menu items to display
defaultItem string First item Initially selected item
buttonProps ButtonProps - Props passed to button elements
variant default | minimal | pills | underline | segments default Variant of the menu
orientation horizontal | vertical horizontal Orientation of the menu
fullWidth boolean false Full width of the menu
Required Props
MenuItem Props Extends <div> HTMLElement
Prop Type Default Description
name string - Menu name this item belongs to
itemName string - Unique identifier for this item

The Menu component comes with several built-in variants to suit different design needs:

A classic menu with subtle shadows and borders:

Clean and simple with bordered items:

Modern pill-shaped buttons with a frosted glass effect:

Elegant underlined navigation style:

Segmented control style with raised active state:

Each variant supports multiple sizes via the buttonProps prop:

Menus can be displayed horizontally or vertically:

Menus can expand to fill their container:

  1. Naming

    • Use clear, descriptive menu names
    • Keep item labels concise
    • Ensure unique identifiers
  2. Content Organization

    • Group related items together
    • Limit number of options
    • Maintain consistent structure

Limited Time Launch Sale

Create intuitive navigation interfaces with our Menu component. Get started with our AstroJS starter template today!

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes