Composite

NavigationTree

Recursive navigation component with collapsible tree structure.

Basic navigation

A flat list with no nesting.

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

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
  },
  {
    label: 'Components',
    href: '/documentation/components',
  },
  {
    label: 'About',
    href: '/about',
  },
];
---

<div class="max-w-xs">
  <NavigationTreeBlock items={items} />
</div>

Expansion strategies

Always expanded

All children visible at all times.

always-expanded
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock items={items} expansionStrategy="always" />
</div>

Active only (default)

Only shows children of active items.

active-only
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock
    items={items}
    expansionStrategy="active-only"
    currentPath="/documentation/composite/Content"
  />
</div>

First level only

Shows only root-level items, no children.

first-level
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock items={items} expansionStrategy="first-level" />
</div>

Depth limited (maxDepth={1})

Expands children up to the specified depth.

max-depth
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock items={items} expansionStrategy="depth" maxDepth={1} />
</div>

Toggleable (interactive)

Click parent items to expand or collapse children. The active path is expanded automatically.

toggleable
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock
    items={items}
    expansionStrategy="toggleable"
    currentPath="/documentation/composite/NavigationTree"
  />
</div>

Toggle modes

Button toggle (default, mobile-friendly)

The entire button toggles children. Good for touch devices with larger tap targets.

button-toggle
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock
    items={items}
    expansionStrategy="toggleable"
    toggleMode="button"
    currentPath="/documentation/composite/ItemsGrid"
  />
</div>

Icon toggle only

Only the icon toggles children; the button navigates to its href. This provides separate controls for navigation and expansion.

icon-toggle
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Documentation',
    href: '/documentation',
    children: [
      {
        label: 'Base',
        href: '/documentation/base',
        children: [
          { label: 'Colors', href: '/documentation/base/Colors' },
          { label: 'Typography', href: '/documentation/base/Typography' },
        ],
      },
      {
        label: 'Composite',
        href: '/documentation/composite',
        children: [
          { label: 'CallToAction', href: '/documentation/composite/CallToAction' },
          { label: 'Content', href: '/documentation/composite/Content' },
          { label: 'ItemsContent', href: '/documentation/composite/ItemsContent' },
          { label: 'NavigationTree', href: '/documentation/composite/NavigationTree' },
        ],
      },
      {
        label: 'Primitives',
        href: '/documentation/primitives',
        children: [
          { label: 'Button', href: '/documentation/primitives/Button' },
          { label: 'Headline', href: '/documentation/primitives/Headline' },
          { label: 'Image', href: '/documentation/primitives/Image' },
        ],
      },
    ],
  },
  {
    label: 'Resources',
    href: '/resources',
    children: [
      {
        label: 'Guides',
        href: '/resources/guides',
        children: [
          { label: 'Quick Start', href: '/resources/guides/quick-start' },
          { label: 'Best Practices', href: '/resources/guides/best-practices' },
          { label: 'Migration Guide', href: '/resources/guides/migration' },
        ],
      },
      {
        label: 'Examples',
        href: '/resources/examples',
        children: [
          { label: 'Dashboard', href: '/resources/examples/dashboard' },
          { label: 'Landing Page', href: '/resources/examples/landing' },
          { label: 'Blog', href: '/resources/examples/blog' },
        ],
      },
    ],
  },
  {
    label: 'Community',
    href: '/community',
    children: [
      {
        label: 'Forum',
        href: '/community/forum',
        children: [
          { label: 'General Discussion', href: '/community/forum/general' },
          { label: 'Help & Support', href: '/community/forum/support' },
          { label: 'Showcase', href: '/community/forum/showcase' },
        ],
      },
      { label: 'GitHub', href: 'https://github.com' },
      { label: 'Discord', href: 'https://discord.com' },
    ],
  },
  {
    label: 'About',
    href: '/about',
    children: [
      { label: 'Team', href: '/about/team' },
      { label: 'Changelog', href: '/about/changelog' },
      { label: 'License', href: '/about/license' },
    ],
  },
];
---

<div class="max-w-md">
  <NavigationTreeBlock
    items={items}
    expansionStrategy="toggleable"
    toggleMode="icon"
    currentPath="/documentation/composite/ItemsGrid"
  />
</div>

Custom configuration

Custom icons

custom-icons
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
    children: [
      { label: 'Installation', href: '/documentation/installation' },
      { label: 'Configuration', href: '/documentation/configuration' },
      { label: 'Quick Start', href: '/documentation/quick-start' },
    ],
  },
  {
    label: 'Components',
    href: '/documentation/components',
    children: [
      { label: 'Buttons', href: '/documentation/components/buttons' },
      { label: 'Forms', href: '/documentation/components/forms' },
      { label: 'Cards', href: '/documentation/components/cards' },
    ],
  },
  {
    label: 'Composite',
    href: '/documentation/composite',
    children: [{ label: 'NavigationTree', href: '/documentation/composite/NavigationTree' }],
  },
  {
    label: 'Layout',
    href: '/documentation/layout',
    children: [
      { label: 'Grid System', href: '/documentation/layout/grid' },
      { label: 'Containers', href: '/documentation/layout/containers' },
    ],
  },
];
---

<div class="max-w-xs">
  <NavigationTreeBlock
    items={items}
    expansionStrategy="always"
    iconName="heroicons:chevron-right"
    rotateIconOnExpand={true}
  />
</div>

Custom button styling

button-styling
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
    children: [
      { label: 'Installation', href: '/documentation/installation' },
      { label: 'Configuration', href: '/documentation/configuration' },
      { label: 'Quick Start', href: '/documentation/quick-start' },
    ],
  },
  {
    label: 'Components',
    href: '/documentation/components',
    children: [
      { label: 'Buttons', href: '/documentation/components/buttons' },
      { label: 'Forms', href: '/documentation/components/forms' },
      { label: 'Cards', href: '/documentation/components/cards' },
    ],
  },
  {
    label: 'Composite',
    href: '/documentation/composite',
    children: [{ label: 'NavigationTree', href: '/documentation/composite/NavigationTree' }],
  },
  {
    label: 'Layout',
    href: '/documentation/layout',
    children: [
      { label: 'Grid System', href: '/documentation/layout/grid' },
      { label: 'Containers', href: '/documentation/layout/containers' },
    ],
  },
];
---

<div class="max-w-xs">
  <NavigationTreeBlock
    items={items}
    expansionStrategy="always"
    inactiveItemConfig={{
      variant: 'outline',
      intent: 'tertiary',
      size: 'sm',
      width: 'full',
    }}
    activeItemConfig={{
      variant: 'solid',
      intent: 'accent',
      size: 'sm',
      width: 'full',
    }}
  />
</div>

Default item styling

Default-config class and icon reach every item.

defaultItemConfig reaches every item; inactiveItemConfig / activeItemConfig layer on top.

Parents keep the iconName chevron over the default icon.

default-config
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
    children: [
      { label: 'Installation', href: '/documentation/installation' },
      { label: 'Configuration', href: '/documentation/configuration' },
      { label: 'Quick Start', href: '/documentation/quick-start' },
    ],
  },
  {
    label: 'Components',
    href: '/documentation/components',
    children: [
      { label: 'Buttons', href: '/documentation/components/buttons' },
      { label: 'Forms', href: '/documentation/components/forms' },
      { label: 'Cards', href: '/documentation/components/cards' },
    ],
  },
  {
    label: 'Composite',
    href: '/documentation/composite',
    children: [{ label: 'NavigationTree', href: '/documentation/composite/NavigationTree' }],
  },
  {
    label: 'Layout',
    href: '/documentation/layout',
    children: [
      { label: 'Grid System', href: '/documentation/layout/grid' },
      { label: 'Containers', href: '/documentation/layout/containers' },
    ],
  },
];
---

<div class="max-w-xs">
  <NavigationTreeBlock
    items={items}
    currentPath="/documentation/composite/NavigationTree"
    expansionStrategy="always"
    defaultItemConfig={{ class: 'tracking-wide', icon: { name: 'mdi:circle-small' } }}
    activeItemConfig={{ class: 'underline' }}
  />
</div>

Active item weight

The active item is semi-bold by default. activeItemConfig.class can change its weight.

active-weight
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
    children: [
      { label: 'Installation', href: '/documentation/installation' },
      { label: 'Configuration', href: '/documentation/configuration' },
      { label: 'Quick Start', href: '/documentation/quick-start' },
    ],
  },
  {
    label: 'Components',
    href: '/documentation/components',
    children: [
      { label: 'Buttons', href: '/documentation/components/buttons' },
      { label: 'Forms', href: '/documentation/components/forms' },
      { label: 'Cards', href: '/documentation/components/cards' },
    ],
  },
  {
    label: 'Composite',
    href: '/documentation/composite',
    children: [{ label: 'NavigationTree', href: '/documentation/composite/NavigationTree' }],
  },
  {
    label: 'Layout',
    href: '/documentation/layout',
    children: [
      { label: 'Grid System', href: '/documentation/layout/grid' },
      { label: 'Containers', href: '/documentation/layout/containers' },
    ],
  },
];
---

<div class="max-w-xs">
  <NavigationTreeBlock
    items={items}
    currentPath="/documentation/composite/NavigationTree"
    expansionStrategy="always"
    activeItemConfig={{ class: 'font-normal' }}
  />
</div>

Children wrapper

childrenClass styles the wrapper around every level of children, here a guide line as in a docs sidebar.

children-class
---
import NavigationTreeBlock from '@alfadormx/blocks/composite/NavigationTree.astro';
import type { NavigationTreeItem } from '@alfadormx/blocks/types/navigationtree';

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
    children: [
      { label: 'Installation', href: '/documentation/installation' },
      { label: 'Configuration', href: '/documentation/configuration' },
      { label: 'Quick Start', href: '/documentation/quick-start' },
    ],
  },
  {
    label: 'Components',
    href: '/documentation/components',
    children: [
      { label: 'Buttons', href: '/documentation/components/buttons' },
      { label: 'Forms', href: '/documentation/components/forms' },
      { label: 'Cards', href: '/documentation/components/cards' },
    ],
  },
  {
    label: 'Composite',
    href: '/documentation/composite',
    children: [{ label: 'NavigationTree', href: '/documentation/composite/NavigationTree' }],
  },
  {
    label: 'Layout',
    href: '/documentation/layout',
    children: [
      { label: 'Grid System', href: '/documentation/layout/grid' },
      { label: 'Containers', href: '/documentation/layout/containers' },
    ],
  },
];
---

<div class="max-w-xs">
  <NavigationTreeBlock
    items={items}
    currentPath="/documentation/composite/NavigationTree"
    expansionStrategy="always"
    childrenClass="ml-3 pl-2 border-l border-border"
    defaultItemConfig={{ size: 'sm' }}
  />
</div>

Current path detection

Without currentPath, the tree matches against the page URL.

Current path: /documentation/composite/NavigationTree

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

const items: NavigationTreeItem[] = [
  {
    label: 'Getting Started',
    href: '/documentation',
    children: [
      { label: 'Installation', href: '/documentation/installation' },
      { label: 'Configuration', href: '/documentation/configuration' },
      { label: 'Quick Start', href: '/documentation/quick-start' },
    ],
  },
  {
    label: 'Components',
    href: '/documentation/components',
    children: [
      { label: 'Buttons', href: '/documentation/components/buttons' },
      { label: 'Forms', href: '/documentation/components/forms' },
      { label: 'Cards', href: '/documentation/components/cards' },
    ],
  },
  {
    label: 'Composite',
    href: '/documentation/composite',
    children: [{ label: 'NavigationTree', href: '/documentation/composite/NavigationTree' }],
  },
  {
    label: 'Layout',
    href: '/documentation/layout',
    children: [
      { label: 'Grid System', href: '/documentation/layout/grid' },
      { label: 'Containers', href: '/documentation/layout/containers' },
    ],
  },
];
---

<div class="max-w-xs space-y-4">
  <p>
    Current path: <code>{Astro.url.pathname}</code>
  </p>
  <NavigationTreeBlock items={items} expansionStrategy="active-only" />
</div>

The active link carries aria-current="page"; a parent rendered as a <summary> toggle keeps the active look without it.

API Reference

PropTypeDefaultDescription
itemsNavigationTreeItem[]—The list of navigation items to render, each a ButtonProps optionally with nested `children` for sub-trees.
currentPathstringAstro.url.pathnameThe path used to determine which item is active (default: `Astro.url.pathname`).
levelnumber0The current nesting depth, compared against `maxDepth` and passed down to sub-trees (default: `0`).
classstring''Additional CSS class(es) applied to the root `<nav>` element (default: `''`).
childrenClassstring—Classes merged onto the wrapper around each item's children, at every depth (default: `'pl-4'`).
iconNamestring'mdi:chevron-right'The icon name shown on items that have children (default: `'mdi:chevron-right'`).
rotateIconOnExpandbooleantrueWhether the expand icon rotates when its item is expanded (default: `true`).
toggleModeToggleMode'button'Whether clicking the whole button or only the icon toggles children; in 'button' mode a parent renders as the `<summary>` of a native `<details>` and its `href` is ignored (default: `'button'`).
defaultItemConfigLayerConfig<Omit<ButtonProps, 'as'>>—Button config merged into every item, in every state, under the state layers.
inactiveItemConfigLayerConfig<Omit<ButtonProps, 'as'>>—Button config merged over `defaultItemConfig` on non-active items.
activeItemConfigLayerConfig<Omit<ButtonProps, 'as'>>—Button config merged over `defaultItemConfig` on the active item; the active item also gets `aria-current="page"` when it renders as a link, which this layer or the item can override.
expansionStrategyExpansionStrategy'active-only'The strategy that decides whether an item's children are shown (default: `'active-only'`).
maxDepthnumberInfinityThe maximum depth expanded when `expansionStrategy` is `'depth'` (default: `Infinity`).