@ecl/mega-menu

中文文档
5.4.1发布于 2026/11/10EUPL-1.2ESM + CJS近 30 天下载 3727

ECL Mega Menu

原始使用文档

ECL Menu

npm package: @ecl/mega-menu

npm install --save @ecl/mega-menu

Parameters

  • "id" (string) (default: random) Unique id for the menu
  • "toggle" (object) (default: phosphor 'list' icon) Toggle (hamburger) button following ECL Button structure
  • "close" (object) (default: phosphor 'x' icon) Close button following ECL Button structure
  • "aria_label" (string) (default: '') Aria label for the main nav element
  • "second_level_aria_label" (string) (default: '') Aria label for second-level sub-lists
  • "third_level_aria_label" (string) (default: '') Aria label for third-level sub-lists
  • "current_aria_label" (string) (default: '') Aria label for the current item
  • "back_label" (string) (default: '') Back button label (mobile navigation)
  • "see_all_label" (string) (default: '') Label for the "View all" link in sub-menus
  • "featured_priority" (string) (default: 'secondary') Which featured panel is visible; can be 'primary', 'secondary'
  • "items" (array) (default: []) Menu items; format: [ { "label" (string) (default: '') Item label "path" (string) (default: '') Item link URL "is_current": (boolean) (optional) Is this the current page? "external" (boolean) (default: false) Is the link external? "sr_external" (string) (default: '') Screen reader label for the external icon "one_level_only" (boolean) (default: false) Disable sub-level navigation for this item "promotional" (boolean) (default: false) Promotional item with custom CSS variable styling "container" (string) (default: '') Raw HTML container filled with content "info" (object) (default: {}) Info column: - "title" (string) Info panel title - "content" (string) Info panel content - "link" (object) "Discover more" link following ECL Link structure "featured" (object) (default: {}) Featured panel: - "title" (string) Featured panel title - "content" (string) Featured panel top content - "items" (array) Items with image, link and description "children" (array) (default: []) Second-level items: { "label" (string) (default: '') Item label "path" (string) (default: '') Item link URL "external" (boolean) (default: false) Is the link external? "sr_external" (string) (default: '') Screen reader label for the external icon "see_all" (boolean) Show "View All" button for this child "see_all_label" (string) "View All" button label "see_all_attributes" (array) Extra attributes for the "View All" button "extra_attributes" (array) Extra attributes for the link } } ]
  • "extra_classes" (string) (default: '') Extra classes (space separated) for the nav element
  • "extra_attributes" (array) (default: []) Extra attributes for the nav element
    • "name" (string) Attribute name, eg. 'data-test'
    • "value" (string) Attribute value, eg: 'data-test-1'

Example:

{% include '@ecl/mega-menu/mega-menu.html.twig' with {
  aria_label: 'Main navigation',
  second_level_aria_label: 'Pages in this section',
  third_level_aria_label: 'Sub-pages in this section',
  current_aria_label: 'Current section',
  toggle: {
    link: {
      label: 'Menu',
      path: exampleLink,
    },
  },
  close: {
    label: 'Close',
  },
  back_label: 'Back',
  items: [
    {
      label: "Menu item",
      path: "example",
      children: [
        {
          label: "Item 1.1",
          path: "/example"
        },
        ...
      ],
    },
    ...
  ],
  extra_classes: "ecl-menu-extra-class,
  extra_attributes: [
    {
      name:"data-ecl-mega-menu",
    },
    ...
    ]
} %}

版本与发布记录

@ecl/mega-menu 共发布 45 个版本,首次发布于 2025/01/22;过去 12 个月发布了 24 个版本。

版本发布日期距今
5.4.1latest2026/11/103 天前
5.4.02026/10/2222 天前
5.3.22026/10/081 个月前
5.3.12026/09/211 个月前
5.3.02026/09/151 个月前
5.2.22026/09/082 个月前

关于 @ecl/mega-menu 的常见问题

@ecl/mega-menu 是什么?

ECL Mega Menu

如何安装 @ecl/mega-menu?

在项目目录运行 npm install @ecl/mega-menu,或使用 pnpm add / yarn add / bun add。

@ecl/mega-menu 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ecl__mega-menu 是否存在。

@ecl/mega-menu 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ecl/mega-menu 可以商用吗?

@ecl/mega-menu 使用 EUPL-1.2 许可。声明的许可为 EUPL-1.2,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@ecl/mega-menu 的下载量有多少?

根据 npm 官方下载统计,@ecl/mega-menu 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,727 次,日均约 124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ecl/mega-menu 还在维护吗?

最新版本 5.4.1 发布于 2026/11/10(3 天前);至今共发布 45 个版本,其中过去 12 个月发布了 24 个;首次发布于 2025/01/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。