- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Trace
Navigation Menu
A collection of links for navigating websites
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideCheck, lucideCircle, lucideInfo } from '@ng-icons/lucide';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-preview',
imports: [HlmNavigationMenuImports, NgIcon, RouterLink],
providers: [provideIcons({ lucideCircle, lucideCheck, lucideInfo })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nav hlmNavigationMenu>
<ul hlmNavigationMenuList class="flex-wrap">
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Getting started</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="w-96">
<li>
<a hlmNavigationMenuLink routerLink="/documentation/introduction">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">Introduction</div>
<div class="text-muted-foreground line-clamp-2">Re-usable components built with Tailwind CSS.</div>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink routerLink="/documentation/installation">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">Installation</div>
<div class="text-muted-foreground line-clamp-2">
How to install dependencies and structure your app.
</div>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink routerLink="/documentation/typography">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">Typography</div>
<div class="text-muted-foreground line-clamp-2">Styles for headings, paragraphs, lists...etc</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<!-- Components Menu -->
<li hlmNavigationMenuItem class="hidden md:flex">
<button hlmNavigationMenuTrigger align="center">Components</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid w-[400px] gap-2 md:w-[500px] md:grid-cols-2 lg:w-[600px]">
@for (component of _components; track $index) {
<li>
<a hlmNavigationMenuLink [href]="component.href">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">{{ component.title }}</div>
<div class="text-muted-foreground line-clamp-2">{{ component.description }}</div>
</div>
</a>
</li>
}
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger align="end">With Icon</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideInfo" />
Backlog
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCircle" />
To Do
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCheck" />
Done
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<a hlmNavigationMenuLink href="/documentation/introduction">Docs</a>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuPreview {
protected readonly _components = [
{
title: 'Alert Dialog',
description: 'A modal dialog that interrupts the user with important content and expects a response.',
href: '/components/alert-dialog',
},
{
title: 'Hover Card',
description: 'For sighted users to preview content available behind a link.',
href: '/components/hover-card',
},
{
title: 'Progress',
description: 'Displays an indicator showing the completion progress of a task.',
href: '/components/progress',
},
{
title: 'Scroll Area',
description: 'Visually or semantically separates content.',
href: '/components/scroll-area',
},
{
title: 'Tabs',
description: 'A set of layered content panels displayed one at a time.',
href: '/components/tabs',
},
{
title: 'Tooltip',
description: 'A popup that displays information on hover or focus.',
href: '/components/tooltip',
},
];
}Installation
ng g @spartan-ng/cli:ui navigation-menunx g @spartan-ng/cli:ui navigation-menuUsage
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';<nav hlmNavigationMenu>
<ul hlmNavigationMenuList>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Home</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<div>Content</div>
</hlm-navigation-menu-content>
<li>
</ul>
</nav>Examples
Vertical
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideCheck, lucideCircle, lucideInfo } from '@ng-icons/lucide';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-vertical',
imports: [HlmNavigationMenuImports, NgIcon],
providers: [provideIcons({ lucideCircle, lucideCheck, lucideInfo })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nav hlmNavigationMenu orientation="vertical">
<ul hlmNavigationMenuList class="w-35 flex-wrap">
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Home</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<li class="row-span-3">
<a
hlmNavigationMenuLink
class="from-muted/50 to-muted flex h-full w-full flex-col justify-end rounded-md bg-linear-to-b p-4 no-underline outline-hidden select-none focus:shadow-md md:p-6"
href="/"
>
<div class="mb-2 text-lg font-medium sm:mt-4">spartan.ng</div>
<p class="text-muted-foreground text-sm leading-tight">
Beautifully designed components built with Tailwind CSS.
</p>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/introduction">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Introduction</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Re-usable components built using Radix UI and Tailwind CSS.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/installation">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Installation</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
How to install dependencies and structure your app.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/typography">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Typography</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Styles for headings, paragraphs, lists...etc
</p>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<!-- Components Menu -->
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Components</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 sm:w-[400px] md:w-[500px] md:grid-cols-2 lg:w-[600px]">
@for (component of _components; track $index) {
<li>
<a hlmNavigationMenuLink [href]="component.href">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">{{ component.title }}</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
{{ component.description }}
</p>
</div>
</a>
</li>
}
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<a hlmNavigationMenuLink class="mx-auto" href="/documentation/introduction">Docs</a>
</li>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>List</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="/components">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Components</div>
<div class="text-muted-foreground">Browse all components in the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="/documentation">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Documentation</div>
<div class="text-muted-foreground">Learn how to use the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="#">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Blog</div>
<div class="text-muted-foreground">Read our latest blog posts.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Simple</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="/components">Components</a>
<a hlmNavigationMenuLink href="/documentation">Documentation</a>
<a hlmNavigationMenuLink href="/blocks">Blocks</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>With Icon</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideInfo" />
Backlog
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCircle" />
To Do
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCheck" />
Done
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuVertical {
protected readonly _components = [
{
title: 'Alert Dialog',
description: 'A modal dialog that interrupts the user with important content and expects a response.',
href: '/components/alert-dialog',
},
{
title: 'Hover Card',
description: 'For sighted users to preview content available behind a link.',
href: '/components/hover-card',
},
{
title: 'Progress',
description: 'Displays an indicator showing the completion progress of a task.',
href: '/components/progress',
},
{
title: 'Scroll Area',
description: 'Visually or semantically separates content.',
href: '/components/scroll-area',
},
{
title: 'Tabs',
description: 'A set of layered content panels displayed one at a time.',
href: '/components/tabs',
},
{
title: 'Tooltip',
description: 'A popup that displays information on hover or focus.',
href: '/components/tooltip',
},
];
}Controlled
The navigation menu's value input can be set to the menu item's id to activate it. Declaratively set navigation menu item stays activated until it is hovered or focused out.
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideCheck, lucideCircle, lucideInfo } from '@ng-icons/lucide';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-controlled',
imports: [HlmNavigationMenuImports, NgIcon],
providers: [provideIcons({ lucideCircle, lucideInfo, lucideCheck })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nav hlmNavigationMenu [(value)]="_value">
<ul hlmNavigationMenuList class="flex-wrap">
<li hlmNavigationMenuItem id="home">
<button hlmNavigationMenuTrigger>Home</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<li class="row-span-3">
<a
hlmNavigationMenuLink
class="from-muted/50 to-muted flex h-full w-full flex-col justify-end rounded-md bg-linear-to-b p-4 no-underline outline-hidden select-none focus:shadow-md md:p-6"
href="/"
>
<div class="mb-2 text-lg font-medium sm:mt-4">spartan.ng</div>
<p class="text-muted-foreground text-sm leading-tight">
Beautifully designed components built with Tailwind CSS.
</p>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/introduction">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Introduction</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Re-usable components built using Radix UI and Tailwind CSS.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/installation">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Installation</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
How to install dependencies and structure your app.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/typography">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Typography</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Styles for headings, paragraphs, lists...etc
</p>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<!-- Components Menu -->
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Components</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 sm:w-[400px] md:w-[500px] md:grid-cols-2 lg:w-[600px]">
@for (component of _components; track $index) {
<li>
<a hlmNavigationMenuLink [href]="component.href">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">{{ component.title }}</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
{{ component.description }}
</p>
</div>
</a>
</li>
}
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<a hlmNavigationMenuLink href="/documentation/introduction">Docs</a>
</li>
<li hlmNavigationMenuItem class="hidden md:block">
<button hlmNavigationMenuTrigger>List</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid w-[300px] gap-4">
<li>
<a hlmNavigationMenuLink href="/components">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Components</div>
<div class="text-muted-foreground">Browse all components in the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="/documentation">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Documentation</div>
<div class="text-muted-foreground">Learn how to use the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="#">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Blog</div>
<div class="text-muted-foreground">Read our latest blog posts.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="hidden md:block">
<button hlmNavigationMenuTrigger>Simple</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="/components">Components</a>
<a hlmNavigationMenuLink href="/documentation">Documentation</a>
<a hlmNavigationMenuLink href="/blocks">Blocks</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="hidden md:block">
<button hlmNavigationMenuTrigger>With Icon</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideInfo" />
Backlog
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCircle" />
To Do
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCheck" />
Done
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuControlled {
protected readonly _value = signal('home');
protected readonly _components = [
{
title: 'Alert Dialog',
description: 'A modal dialog that interrupts the user with important content and expects a response.',
href: '/components/alert-dialog',
},
{
title: 'Hover Card',
description: 'For sighted users to preview content available behind a link.',
href: '/components/hover-card',
},
{
title: 'Progress',
description: 'Displays an indicator showing the completion progress of a task.',
href: '/components/progress',
},
{
title: 'Scroll Area',
description: 'Visually or semantically separates content.',
href: '/components/scroll-area',
},
{
title: 'Tabs',
description: 'A set of layered content panels displayed one at a time.',
href: '/components/tabs',
},
{
title: 'Tooltip',
description: 'A popup that displays information on hover or focus.',
href: '/components/tooltip',
},
];
}Nested
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideCheck, lucideCircle, lucideInfo } from '@ng-icons/lucide';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-nested',
imports: [HlmNavigationMenuImports, NgIcon],
providers: [provideIcons({ lucideCircle, lucideInfo, lucideCheck })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nav hlmNavigationMenu>
<ul hlmNavigationMenuList class="flex-wrap">
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Root</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<nav hlmNavigationMenu orientation="vertical">
<ul hlmNavigationMenuList class="w-35 flex-wrap">
<li hlmNavigationMenuItem class="w-full">
<button hlmNavigationMenuTrigger class="w-full">Home</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<li class="row-span-3">
<a
hlmNavigationMenuLink
class="from-muted/50 to-muted flex h-full w-full flex-col justify-end rounded-md bg-linear-to-b p-4 no-underline outline-hidden select-none focus:shadow-md md:p-6"
href="/"
>
<div class="mb-2 text-lg font-medium sm:mt-4">spartan.ng</div>
<p class="text-muted-foreground text-sm leading-tight">
Beautifully designed components built with Tailwind CSS.
</p>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/introduction">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Introduction</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Re-usable components built using Radix UI and Tailwind CSS.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/installation">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Installation</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
How to install dependencies and structure your app.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/typography">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Typography</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Styles for headings, paragraphs, lists...etc
</p>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<!-- Components Menu -->
<li hlmNavigationMenuItem class="w-full">
<button hlmNavigationMenuTrigger class="w-full">Components</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 sm:w-[400px] md:w-[500px] md:grid-cols-2 lg:w-[600px]">
@for (component of _components; track $index) {
<li>
<a hlmNavigationMenuLink [href]="component.href">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">{{ component.title }}</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
{{ component.description }}
</p>
</div>
</a>
</li>
}
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="w-full">
<button hlmNavigationMenuTrigger class="w-full">List</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid w-[300px] gap-4">
<li>
<a hlmNavigationMenuLink href="/components">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Components</div>
<div class="text-muted-foreground">Browse all components in the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="/documentation">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Documentation</div>
<div class="text-muted-foreground">Learn how to use the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="#">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Blog</div>
<div class="text-muted-foreground">Read our latest blog posts.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="w-full">
<button hlmNavigationMenuTrigger class="w-full">Simple</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="/components">Components</a>
<a hlmNavigationMenuLink href="/documentation">Documentation</a>
<a hlmNavigationMenuLink href="/blocks">Blocks</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="w-full">
<button hlmNavigationMenuTrigger class="w-full">With Icon</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideInfo" />
Backlog
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCircle" />
To Do
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCheck" />
Done
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
</ul>
</nav>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<a hlmNavigationMenuLink href="/documentation/introduction">Docs</a>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuNested {
protected readonly _components = [
{
title: 'Alert Dialog',
description: 'A modal dialog that interrupts the user with important content and expects a response.',
href: '/components/alert-dialog',
},
{
title: 'Hover Card',
description: 'For sighted users to preview content available behind a link.',
href: '/components/hover-card',
},
{
title: 'Progress',
description: 'Displays an indicator showing the completion progress of a task.',
href: '/components/progress',
},
{
title: 'Scroll Area',
description: 'Visually or semantically separates content.',
href: '/components/scroll-area',
},
{
title: 'Tabs',
description: 'A set of layered content panels displayed one at a time.',
href: '/components/tabs',
},
{
title: 'Tooltip',
description: 'A popup that displays information on hover or focus.',
href: '/components/tooltip',
},
];
}Open on Click
Set openOn="click" to require a click to open the menu initially. Once a menu is open, hovering still switches between menu items.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideCheck, lucideCircle, lucideInfo } from '@ng-icons/lucide';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-open-on-click',
imports: [HlmNavigationMenuImports, NgIcon],
providers: [provideIcons({ lucideCircle, lucideCheck, lucideInfo })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nav hlmNavigationMenu openOn="click">
<ul hlmNavigationMenuList class="flex-wrap">
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Home</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<li class="row-span-3">
<a
hlmNavigationMenuLink
class="from-muted/50 to-muted flex h-full w-full flex-col justify-end rounded-md bg-linear-to-b p-4 no-underline outline-hidden select-none focus:shadow-md md:p-6"
href="/"
>
<div class="mb-2 text-lg font-medium sm:mt-4">spartan.ng</div>
<p class="text-muted-foreground text-sm leading-tight">
Beautifully designed components built with Tailwind CSS.
</p>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/introduction">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Introduction</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Re-usable components built using Radix UI and Tailwind CSS.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/installation">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Installation</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
How to install dependencies and structure your app.
</p>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink href="/documentation/typography">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">Typography</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
Styles for headings, paragraphs, lists...etc
</p>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<!-- Components Menu -->
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>Components</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid gap-2 sm:w-[400px] md:w-[500px] md:grid-cols-2 lg:w-[600px]">
@for (component of _components; track $index) {
<li>
<a hlmNavigationMenuLink [href]="component.href">
<div class="flex flex-col gap-1 text-sm">
<div class="text-sm leading-none font-medium">{{ component.title }}</div>
<p class="text-muted-foreground line-clamp-2 text-sm leading-snug">
{{ component.description }}
</p>
</div>
</a>
</li>
}
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<a hlmNavigationMenuLink href="/documentation/introduction">Docs</a>
</li>
<li hlmNavigationMenuItem class="hidden md:block">
<button hlmNavigationMenuTrigger>List</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid w-[300px] gap-4">
<li>
<a hlmNavigationMenuLink href="/components">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Components</div>
<div class="text-muted-foreground">Browse all components in the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="/documentation">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Documentation</div>
<div class="text-muted-foreground">Learn how to use the library.</div>
</div>
</a>
<a hlmNavigationMenuLink href="#">
<div class="flex flex-col gap-1 text-sm">
<div class="font-medium">Blog</div>
<div class="text-muted-foreground">Read our latest blog posts.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="hidden md:block">
<button hlmNavigationMenuTrigger>Simple</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="/components">Components</a>
<a hlmNavigationMenuLink href="/documentation">Documentation</a>
<a hlmNavigationMenuLink href="/blocks">Blocks</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem class="hidden md:block">
<button hlmNavigationMenuTrigger>With Icon</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul>
<li>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideInfo" />
Backlog
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCircle" />
To Do
</a>
<a hlmNavigationMenuLink href="#">
<ng-icon name="lucideCheck" />
Done
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuOpenOnClick {
protected readonly _components = [
{
title: 'Alert Dialog',
description: 'A modal dialog that interrupts the user with important content and expects a response.',
href: '/components/alert-dialog',
},
{
title: 'Hover Card',
description: 'For sighted users to preview content available behind a link.',
href: '/components/hover-card',
},
{
title: 'Progress',
description: 'Displays an indicator showing the completion progress of a task.',
href: '/components/progress',
},
{
title: 'Scroll Area',
description: 'Visually or semantically separates content.',
href: '/components/scroll-area',
},
{
title: 'Tabs',
description: 'A set of layered content panels displayed one at a time.',
href: '/components/tabs',
},
{
title: 'Tooltip',
description: 'A popup that displays information on hover or focus.',
href: '/components/tooltip',
},
];
}Align
Use the align input to control how the content aligns relative to the trigger.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-align',
imports: [HlmNavigationMenuImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nav hlmNavigationMenu>
<ul hlmNavigationMenuList class="flex-wrap">
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger align="start">Start</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="w-48">
<li>
<a hlmNavigationMenuLink href="/">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">Aligned Start</div>
<div class="text-muted-foreground line-clamp-2">Content aligns to the start of the trigger.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger align="center">Center</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="w-48">
<li>
<a hlmNavigationMenuLink href="/">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">Aligned Center</div>
<div class="text-muted-foreground line-clamp-2">Content aligns to the center of the trigger.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger align="end">End</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="w-48">
<li>
<a hlmNavigationMenuLink href="/">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">Aligned End</div>
<div class="text-muted-foreground line-clamp-2">Content aligns to the end of the trigger.</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuAlign {}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
import { Directionality } from '@angular/cdk/bidi';
import { Component, computed, effect, inject, untracked } from '@angular/core';
import { RouterLink } from '@angular/router';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmNavigationMenuImports } from '@spartan-ng/helm/navigation-menu';
@Component({
selector: 'spartan-navigation-menu-rtl',
imports: [HlmNavigationMenuImports, RouterLink],
providers: [Directionality],
host: {
'[dir]': '_dir()',
},
template: `
<nav hlmNavigationMenu>
<ul hlmNavigationMenuList class="flex-wrap">
<li hlmNavigationMenuItem>
<button hlmNavigationMenuTrigger>{{ _t()['gettingStarted'] }}</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="w-96">
<li>
<a hlmNavigationMenuLink routerLink="/documentation/introduction">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">{{ _t()['introduction'] }}</div>
<div class="text-muted-foreground line-clamp-2">{{ _t()['introductionDesc'] }}</div>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink routerLink="/documentation/installation">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">{{ _t()['installation'] }}</div>
<div class="text-muted-foreground line-clamp-2">{{ _t()['installationDesc'] }}</div>
</div>
</a>
</li>
<li>
<a hlmNavigationMenuLink routerLink="/documentation/typography">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">{{ _t()['typography'] }}</div>
<div class="text-muted-foreground line-clamp-2">{{ _t()['typographyDesc'] }}</div>
</div>
</a>
</li>
</ul>
</hlm-navigation-menu-content>
</li>
<!-- Components Menu -->
<li hlmNavigationMenuItem class="hidden md:flex">
<button hlmNavigationMenuTrigger>{{ _t()['components'] }}</button>
<hlm-navigation-menu-content *hlmNavigationMenuPortal>
<ul class="grid w-[400px] gap-2 md:w-[500px] md:grid-cols-2 lg:w-[600px]">
@for (component of _components; track $index) {
<li>
<a hlmNavigationMenuLink [href]="component.href">
<div class="flex flex-col gap-1 text-sm">
<div class="leading-none font-medium">{{ _t()[component.titleKey] }}</div>
<div class="text-muted-foreground line-clamp-2">{{ _t()[component.descriptionKey] }}</div>
</div>
</a>
</li>
}
</ul>
</hlm-navigation-menu-content>
</li>
<li hlmNavigationMenuItem>
<a hlmNavigationMenuLink href="/documentation/introduction">{{ _t()['docs'] }}</a>
</li>
</ul>
</nav>
`,
})
export class NavigationMenuRtl {
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {
gettingStarted: 'Getting started',
introduction: 'Introduction',
introductionDesc: 'Re-usable components built with Tailwind CSS.',
installation: 'Installation',
installationDesc: 'How to install dependencies and structure your app.',
typography: 'Typography',
typographyDesc: 'Styles for headings, paragraphs, lists...etc',
components: 'Components',
alertDialog: 'Alert Dialog',
alertDialogDesc: 'A modal dialog that interrupts the user with important content and expects a response.',
hoverCard: 'Hover Card',
hoverCardDesc: 'For sighted users to preview content available behind a link.',
progress: 'Progress',
progressDesc:
'Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.',
scrollArea: 'Scroll-area',
scrollAreaDesc: 'Visually or semantically separates content.',
tabs: 'Tabs',
tabsDesc: 'A set of layered sections of content—known as tab panels—that are displayed one at a time.',
tooltip: 'Tooltip',
tooltipDesc:
'A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.',
withIcon: 'With Icon',
backlog: 'Backlog',
toDo: 'To Do',
done: 'Done',
docs: 'Docs',
},
},
ar: {
dir: 'rtl',
values: {
gettingStarted: 'البدء',
introduction: 'مقدمة',
introductionDesc: 'مكونات قابلة لإعادة الاستخدام مبنية باستخدام Tailwind CSS.',
installation: 'التثبيت',
installationDesc: 'كيفية تثبيت التبعيات وتنظيم تطبيقك.',
typography: 'الطباعة',
typographyDesc: 'أنماط للعناوين والفقرات والقوائم...إلخ',
components: 'المكونات',
alertDialog: 'حوار التنبيه',
alertDialogDesc: 'حوار نافذة يقطع المستخدم بمحتوى مهم ويتوقع استجابة.',
hoverCard: 'بطاقة التحويم',
hoverCardDesc: 'للمستخدمين المبصرين لمعاينة المحتوى المتاح خلف الرابط.',
progress: 'التقدم',
progressDesc: 'يعرض مؤشرًا يوضح تقدم إتمام المهمة، عادةً يتم عرضه كشريط تقدم.',
scrollArea: 'منطقة التمرير',
scrollAreaDesc: 'يفصل المحتوى بصريًا أو دلاليًا.',
tabs: 'التبويبات',
tabsDesc: 'مجموعة من أقسام المحتوى المتعددة الطبقات—المعروفة بألواح التبويب—التي يتم عرضها واحدة في كل مرة.',
tooltip: 'تلميح',
tooltipDesc:
'نافذة منبثقة تعرض معلومات متعلقة بعنصر عندما يتلقى العنصر التركيز على لوحة المفاتيح أو عند تحويم الماوس فوقه.',
withIcon: 'مع أيقونة',
backlog: 'قائمة الانتظار',
toDo: 'المهام',
done: 'منجز',
docs: 'الوثائق',
},
},
he: {
dir: 'rtl',
values: {
gettingStarted: 'התחלה',
introduction: 'הקדמה',
introductionDesc: 'רכיבים לשימוש חוזר שנבנו עם Tailwind CSS.',
installation: 'התקנה',
installationDesc: 'כיצד להתקין תלויות ולבנות את האפליקציה שלך.',
typography: 'טיפוגרפיה',
typographyDesc: "סגנונות לכותרות, פסקאות, רשימות...וכו'",
components: 'רכיבים',
alertDialog: 'דיאלוג התראה',
alertDialogDesc: 'דיאלוג מודאלי שמפריע למשתמש עם תוכן חשוב ומצפה לתגובה.',
hoverCard: 'כרטיס ריחוף',
hoverCardDesc: 'למשתמשים רואים כדי להציג תצוגה מקדימה של תוכן זמין מאחורי קישור.',
progress: 'התקדמות',
progressDesc: 'מציג אינדיקטור המציג את התקדמות ההשלמה של משימה, בדרך כלל מוצג כסרגל התקדמות.',
scrollArea: 'אזור גלילה',
scrollAreaDesc: 'מפריד תוכן חזותית או סמנטית.',
tabs: 'כרטיסיות',
tabsDesc: 'קבוצה של חלקי תוכן מרובדים—המכונים לוחות כרטיסיות—המוצגים אחד בכל פעם.',
tooltip: 'טולטיפ',
tooltipDesc: 'חלון קופץ המציג מידע הקשור לאלמנט כאשר האלמנט מקבל מיקוד מקלדת או כאשר העכבר מרחף מעליו.',
withIcon: 'עם אייקון',
backlog: 'רשימת המתנה',
toDo: 'לעשות',
done: 'הושלם',
docs: 'תיעוד',
},
},
};
protected readonly _components = [
{
titleKey: 'alertDialog' as const,
descriptionKey: 'alertDialogDesc' as const,
href: '/components/alert-dialog',
},
{
titleKey: 'hoverCard' as const,
descriptionKey: 'hoverCardDesc' as const,
href: '/components/hover-card',
},
{
titleKey: 'progress' as const,
descriptionKey: 'progressDesc' as const,
href: '/components/progress',
},
{
titleKey: 'scrollArea' as const,
descriptionKey: 'scrollAreaDesc' as const,
href: '/components/scroll-area',
},
{
titleKey: 'tabs' as const,
descriptionKey: 'tabsDesc' as const,
href: '/components/tabs',
},
{
titleKey: 'tooltip' as const,
descriptionKey: 'tooltipDesc' as const,
href: '/components/tooltip',
},
];
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
private readonly _directionality = inject(Directionality);
constructor() {
effect(() => {
const dir = this._dir();
untracked(() => this._directionality.valueSignal.set(dir));
});
}
}Brain API
BrnNavigationMenuContent
Selector: [brnNavigationMenuContent]
ExportAs: brnNavigationMenuContent
BrnNavigationMenuItem
Selector: li[brnNavigationMenuItem]
ExportAs: brnNavigationMenuItem
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-navigation-menu-item-${++BrnNavigationMenuItem._id}` | The id of the navigation menu item |
BrnNavigationMenuLink
Selector: a[brnNavigationMenuLink]
ExportAs: brnNavigationMenuLink
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| active | boolean | undefined | undefined | Used to identify the link as the currently active page. |
| disabled | boolean | false | - |
BrnNavigationMenuList
Selector: ul[brnNavigationMenuList]
ExportAs: brnNavigationMenuList
BrnNavigationMenuTrigger
Selector: button[brnNavigationMenuTrigger]
ExportAs: brnNavigationMenuTrigger
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| align | MenuAlign | 'start' | - |
| disabled | boolean | false | - |
BrnNavigationMenu
Selector: nav[brnNavigationMenu]
ExportAs: brnNavigationMenu
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| delayDuration | number | 200 | The duration from when the mouse enters a trigger until the content opens. |
| skipDelayDuration | number | 300 | How much time a user has to enter another trigger without incurring a delay again. |
| openOn | 'hover' | 'click' | 'hover' | Controls whether the menu opens on hover or click. When 'click', initial open requires a click, but hover still switches between items once open. |
| orientation | 'horizontal' | 'vertical' | 'horizontal' | The orientation of the menu. |
| value | string | - | The controlled value of the menu item to activate. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| valueChange | string | - | The controlled value of the menu item to activate. |
Helm API
HlmNavigationMenuContent
Selector: [hlmNavigationMenuContent],hlm-navigation-menu-content
ExportAs: hlmNavigationMenuContent
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| navOffset | number | 1.5 | - |
HlmNavigationMenuItem
Selector: li[hlmNavigationMenuItem]
ExportAs: hlmNavigationMenuItem
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-navigation-menu-item-${++BrnNavigationMenuItem._id}` | The id of the navigation menu item |
HlmNavigationMenuLink
Selector: a[hlmNavigationMenuLink]
ExportAs: hlmNavigationMenuLink
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| active | boolean | undefined | undefined | Used to identify the link as the currently active page. |
HlmNavigationMenuList
Selector: ul[hlmNavigationMenuList]
ExportAs: hlmNavigationMenuList
HlmNavigationMenuPortal
Selector: [hlmNavigationMenuPortal]
ExportAs: hlmNavigationMenuPortal
HlmNavigationMenuTrigger
Selector: button[hlmNavigationMenuTrigger]
ExportAs: hlmNavigationMenuTrigger
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| align | MenuAlign | 'start' | - |
HlmNavigationMenu
Selector: nav[hlmNavigationMenu]
ExportAs: hlmNavigationMenu
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | The controlled value of the menu item to activate. |
| delayDuration | number | 200 | The duration from when the mouse enters a trigger until the content opens. |
| skipDelayDuration | number | 300 | How much time a user has to enter another trigger without incurring a delay again. |
| orientation | 'horizontal' | 'vertical' | 'horizontal' | The orientation of the menu. |
| openOn | 'hover' | 'click' | 'hover' | Controls whether the menu opens on hover or click. When 'click', initial open requires a click, but hover still switches between items once open. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| valueChange | string | - | The controlled value of the menu item to activate. |
On This Page