Navigation Menu

站点导航:nav 中的链接和触发器,每个触发器可通过点击、悬停或键盘展开一个链接面板;使用展开按钮和真正的链接,而不是 ARIA 菜单。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 暂不可用

用法

导入

ts
import {
  SoneNavigationMenuContentDirective,
  SoneNavigationMenuDirective,
  SoneNavigationMenuItemDirective,
  SoneNavigationMenuLinkDirective,
  SoneNavigationMenuListDirective,
  SoneNavigationMenuTriggerDirective,
} from "@surface-one/angular/navigation-menu";

API 参考

SoneNavigationMenuContentDirective指令

`[soneNavigationMenuContent]` — the panel of links its trigger reveals, under the item. `hidden` while closed (still in the page); Escape closes it and focuses the trigger, and following one of its links closes it.

选择器
[soneNavigationMenuContent]

SoneNavigationMenuDirective指令

`nav[soneNavigationMenu]` — site navigation (shadcn/ui and Radix NavigationMenu, spartan/ui Navigation Menu): a list of links and disclosure triggers, each trigger revealing a content panel of links under it. It is navigation, not an ARIA menu: the triggers are buttons with `aria-expanded` / `aria-controls`, the links are links (`active` sets `aria-current="page"`), and Tab moves through them in order. One content is open at a time — `[(value)]` names it; it opens on click, on ArrowDown (on its first link) and on hover after `openDelay`, and closes `closeDelay` after the pointer leaves, on Escape, on a click outside and when focus leaves the menu. ArrowLeft / ArrowRight, Home and End move between the top-level items. Name it with `aria-label`. The contents stay in the page while closed (`hidden`), so the links are prerendered for search engines.

选择器
nav[soneNavigationMenu]
导出为
soneNavigationMenu
输入
名称类型 默认值
value双向

The open item's `value`, or `null` — `[(value)]`.

string | nullnull
openDelay

ms from resting the pointer on a trigger to opening (when nothing is open yet).

number200
closeDelay

ms from leaving an item to closing.

number150

SoneNavigationMenuItemDirective指令

`[soneNavigationMenuItem]` — one `<li>`: a link, or a trigger and its content. The pointer resting anywhere on it (trigger or open content) keeps it open.

选择器
[soneNavigationMenuItem]
输入
名称类型 默认值
value

What `[(value)]` of the menu says when this item is open (generated when left out).

string | nullnull

SoneNavigationMenuLinkDirective指令

`[soneNavigationMenuLink]` — a link, at the top level or in a content. `active` marks the current page (`aria-current="page"`, `data-active`).

选择器
[soneNavigationMenuLink]
输入
名称类型 默认值
activebooleanfalse

SoneNavigationMenuListDirective指令

`[soneNavigationMenuList]` — the `<ul>` of top-level items; arrow keys move along it.

选择器
[soneNavigationMenuList]

SoneNavigationMenuTriggerDirective指令

`[soneNavigationMenuTrigger]` — the button that reveals its item's content (`aria-expanded`, `aria-controls`), with a chevron drawn by CSS.

选择器
[soneNavigationMenuTrigger]