Composite

NavigationTreeHorizontal

Horizontal navigation menu with dropdown support.

Horizontal navigation component with dropdown menus for items with children. Supports hover and click trigger modes.

Basic horizontal menu

Simple horizontal navigation without dropdowns.

basic
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock items={items} />

Hover dropdowns (default)

Dropdown menus appear on hover.

hover
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock items={items} trigger="hover" />

Click dropdowns

Dropdown menus appear on click. Click outside or press Escape to close.

click
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock items={items} trigger="click" />

Icon position

Parent chevrons sit after the label by default; set defaultItemConfig.iconPosition to move them.

icon-left
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock items={items} defaultItemConfig={{ iconPosition: 'left' }} />

dropdownClass styles the panel; a display utility in it doesn’t open the dropdown.

dropdown-class
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock items={items} trigger="click" dropdownClass="flex flex-col" />

Default icon and chevron

Parents keep their chevron over defaultItemConfig.icon; set iconName to change it.

default-icon
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock
  items={items}
  defaultItemConfig={{ icon: { name: 'mdi:circle-small' } }}
/>
icon-name
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock items={items} iconName="heroicons:chevron-double-down" />

Current page

The item whose href matches currentPath (default: the page URL) gets aria-current="page" and activeItemConfig; the rest get inactiveItemConfig. Matching is exact, so a hash link such as /#pricing is never current. A parent is not marked for a current child, and a click-mode parent, being a button, keeps the look without aria-current.

current-path
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<div class="space-y-4">
  <NavigationTreeHorizontalBlock items={items} currentPath="/about" />
  <NavigationTreeHorizontalBlock
    items={items}
    currentPath="/services/design"
    activeItemConfig={{ class: 'underline' }}
  />
</div>

Control dropdown alignment: left (default), center, or right.

dropdown-position
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<div class="space-y-6">
  <div class="space-y-2">
    <p class="text-sm font-semibold">Left aligned</p>
    <NavigationTreeHorizontalBlock items={items} dropdownPosition="left" />
  </div>
  <div class="space-y-2">
    <p class="text-sm font-semibold">Center aligned</p>
    <NavigationTreeHorizontalBlock items={items} dropdownPosition="center" />
  </div>
  <div class="space-y-2">
    <p class="text-sm font-semibold">Right aligned</p>
    <NavigationTreeHorizontalBlock items={items} dropdownPosition="right" />
  </div>
</div>

Custom styling

Customize appearance with default item configuration and custom classes.

custom-styling
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<NavigationTreeHorizontalBlock
  items={items}
  defaultItemConfig={{
    variant: 'outline',
    intent: 'primary',
    size: 'md',
  }}
  class="gap-3"
  dropdownClass="bg-background border-primary rounded-none space-y-1"
/>

Button variants

Use different button variants for the navigation items.

button-variants
---
import NavigationTreeHorizontalBlock from '@alfadormx/blocks/composite/NavigationTreeHorizontal.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  { label: 'Home', href: '/' },
  {
    label: 'Products',
    children: [
      { label: 'Product 1', href: '/products/1' },
      { label: 'Product 2', href: '/products/2' },
      { label: 'Product 3', href: '/products/3' },
    ],
  },
  {
    label: 'Services',
    children: [
      { label: 'Consulting', href: '/services/consulting' },
      { label: 'Development', href: '/services/development' },
      { label: 'Design', href: '/services/design' },
    ],
  },
  { label: 'About', href: '/about' },
  { label: 'Contact', href: '/contact' },
];
---

<div class="space-y-6">
  <div class="space-y-2">
    <p class="text-sm font-semibold">Ghost (default)</p>
    <NavigationTreeHorizontalBlock items={items} defaultItemConfig={{ variant: 'ghost' }} />
  </div>
  <div class="space-y-2">
    <p class="text-sm font-semibold">Solid</p>
    <NavigationTreeHorizontalBlock
      items={items}
      defaultItemConfig={{ variant: 'solid', intent: 'primary' }}
    />
  </div>
  <div class="space-y-2">
    <p class="text-sm font-semibold">Outline</p>
    <NavigationTreeHorizontalBlock
      items={items}
      defaultItemConfig={{ variant: 'outline', intent: 'accent' }}
    />
  </div>
</div>

Usage notes

Structure. Each item in the items array follows the ButtonProps interface. Items with a children array render as dropdown menus.

Trigger modes. Hover: dropdowns appear on mouse hover (best for desktop). Click: dropdowns appear on click and close when clicking outside or pressing Escape (better for touch devices).

Depth limitation. This component is designed for 1–2 levels (parent → children). For deeply nested navigation, use the vertical NavigationTree component instead.

API Reference

PropTypeDefaultDescription
itemsNavigationTreeItem[][]Navigation items to render as top-level buttons; items with a `children` array render a dropdown menu; with `trigger: 'click'`, a parent's `href` is cleared so the button toggles its dropdown (default: []).
currentPathstringAstro.url.pathnamePath matched against each item's own `href` to find the current page; exact match after trimming one trailing slash, and an href with `#` or `?` never matches (default: `Astro.url.pathname`).
triggerNavigationTreeHorizontalTrigger'hover'How dropdown menus are triggered: 'hover' shows on mouse hover, 'click' toggles on click and closes on outside click or Escape (default: 'hover').
dropdownPosition'left' | 'center' | 'right''left'Horizontal alignment of dropdown menus relative to their parent nav item (default: 'left').
classstring''Custom classes merged onto the outer nav container element (default: '').
itemClassstring''Custom classes merged onto each nav item wrapper div (default: '').
dropdownClassstring''Custom classes merged onto each dropdown panel; visibility is owned by the wrapper, so display utilities are safe (default: '').
defaultItemConfigLayerConfig<ButtonProps>—ButtonProps applied as shared defaults to top-level and child buttons in every state, above the built-in base and state layers, below `activeItemConfig`/`inactiveItemConfig` and each item's own props.
activeItemConfigLayerConfig<ButtonProps>—ButtonProps layered on the item whose `href` matches `currentPath`, above `defaultItemConfig`; that item also gets `aria-current="page"` when it renders as a link, which this layer or the item can override (default: ghost/primary).
inactiveItemConfigLayerConfig<ButtonProps>—ButtonProps layered on every item that isn't current, above `defaultItemConfig` (default: ghost/neutral).
iconNamestring'heroicons:chevron-down'Icon name for the chevron on items with children; sits above `defaultItemConfig`, so a layer icon can't replace it (default: 'heroicons:chevron-down').