Menus


CollapsibleMenu

The CollapsibleMenu component automatically moves menu items into an overflow dropdown when there isn’t enough horizontal space to display them all. Perfect for responsive navigation bars and headers.

Features:

Basic Usage

---
import { CollapsibleMenu } from '@dynamic-type/ddi';
---

<CollapsibleMenu
    buttonClass="custom-button-style"
    popoverClass="custom-popover-style"
    menuItemsClass="custom-menu-style"
    collapseAll
>
    <a href="/item-1" class="button tertiary">Item 1</a>
    <a href="/item-2" class="button tertiary">Item 2</a>
    <a href="/item-3" class="button tertiary">Item 3</a>
</CollapsibleMenu>

Attributes

Custom classes - resize to see overflow behavior
Logo
Set `collapseAll` to put all items in overflow menu if the menu overflows.

VerticalMenu

The VerticalMenu component creates a dropdown menu triggered by a button. It displays menu items in a vertical popover when activated, perfect for navigation submenus and grouped actions.

Features:

Basic Usage

---
import { VerticalMenu } from '@dynamic-type/ddi';
---

<VerticalMenu
    name="Menu Name"
    buttonClass="custom-button-style"
    itemsClass="custom-items-style"
>
    <a href="/item-1" class="button tertiary">Item 1</a>
    <a href="/item-2" class="button tertiary">Item 2</a>
    <a href="/item-3" class="button tertiary">Item 3</a>
</VerticalMenu>

Custom Button

<VerticalMenu name="Custom Menu">
    <button slot="vertical-menu-button" class="custom-trigger-button">
        Custom Trigger
        <svg><!-- custom icon --></svg>
    </button>
    <a href="/item-1">Item 1</a>
    <a href="/item-2">Item 2</a>
</VerticalMenu>

With Unwrap Prefix

<VerticalMenu 
    name="Services" 
    unwrapPrefix={true}
>
    <a href="/web-design" class="button tertiary">Web Design</a>
    <a href="/development" class="button tertiary">Development</a>
    <a href="/consulting" class="button tertiary">Consulting</a>
</VerticalMenu>

When this menu is moved to overflow in a CollapsibleMenu, items become “Services – Web Design”, “Services – Development”, etc.

Attributes

Slots

Basic vertical menu
Styled vertical menu

Combining CollapsibleMenu with VerticalMenu

When you combine these components, VerticalMenu items can be automatically unwrapped and prefixed when the CollapsibleMenu moves them to overflow. This provides better UX by showing users which submenu the items came from.

Put vertical menus in collapsible menu - resize to see unwrapPrefix in action