@ecl/site-header

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

ECL Site Header

原始使用文档
文档目录3 节
  1. Parameters
  2. Deprecated
  3. Example :

ECL Site Header component

npm package: @ecl/site-header

npm install --save @ecl/site-header

Parameters

  • "logged" (boolean) (default: false): Whether the user is logged in or not
  • "menu" (associative array): Menu content, if any. Uses ECL Menu structure
  • "site_name" (string) (default: '') Site name
  • "site_name_mobile_only" (boolean): Whether the site name should be hidden on desktop or not
  • "logo" (associative array) (default: predefined structure): Logo image settings. format:
    • "title" (string) (default: ''): Logo title attribute.
    • "alt" (string) (default: ''): Logo alt attribute.
    • "breakpoint": (string) (default: 's') Expected value in EU is "l"
    • "href" (string) (default: ''): Logo URL.
    • "src_desktop" (string) (default: ''): Desktop logo image file path
    • "src_mobile" (string) (default: ''): Mobile logo image file path for EU only
    • "size": (string) (default: 'l'): Three sizes in desktop (s, m, l)
  • "login_box" (associative array) format:
    • "id": (string) Id of the box
    • "description" (string) Label for the logged in users
    • "label" (string) Log out label
    • "href" (string) Url of the link
  • "login_toggle" (associative array) format:
    • "label_not_logged" (string) Label for the anonymous users
    • "href_not_logged" (optional) (string) Link to the login form. If not provided, the toggle renders as a button
    • "label_logged" (string) Label for the logged in users
    • "href_logged" (optional) (string) Link to the logout form. If not provided, the toggle renders as a button
  • "custom_action" (associative array) (default: {}):
    • "link" (object) (default: predefined structure) predefined structure for the Link component. If "path" is not provided, the toggle renders as a button
    • "icon" (optional) (associative array) OR (array) of associate arrays - Default structure of the icon component, but extra_classes is an internal key. The name has to be non empty for the icon to be printed.
    • "overlay": (associative array) (optional):
      • "title": (string) (default: '') Overlay title
      • "close": (associative array) (default: {})
      • "content": (string) (default: '') HTML for the popover
  • "language_selector" (associative array) (default: predefined structure): Language switcher settings. format:
    • "href" (optional) (string) (default: ''): URL for switcher. If not provided, the toggle renders as a button
    • "label" (string) (default: ''): Switcher language label, eg. 'English' in eu, 'EN' in ec
    • "aria_label" (string) (default: ''): Switcher language aria label
    • "eu_category" (string) (default: ''): Label for EU languages
    • "non_eu_category" (string) (default: ''): Label for non-EU languages
    • "overlay" (associative array) (default: predefined structure): Overlay language switcher settings. format:
      • "close": (associative array) (default: {}): Close button, following ECL Button structure
      • "title" (string) (default: ''): Overlay title, eg. 'Select your language'.
      • "items" (array) (default: []): (array) (default: []): format:
        • "lang" (string) (default: '') Item language code, eg. 'en', 'fr', etc.
        • "label" (string) (default: '') Item language label, eg. 'English', 'Français', etc.
        • "path" (string) (default: '') Item language URL eg. '/example#language_en'.
        • "active" (boolean) (default: false) define if item is the active language.
      • "non_eu_items" (array) (default: []): (array) (default: []): format:
        • "lang" (string) (default: '') Item language code, eg. 'en', 'fr', etc.
        • "label" (string) (default: '') Item language label, eg. 'English', 'Français', etc.
        • "path" (string) (default: '') Item language URL eg. '/example#language_en'.
        • "active" (boolean) (default: false) define if item is the active language.
  • "search_toggle" (associative array) format:
    • "label" (string) Label of the element
    • "href" (optional) (string) Link of the element. If not provided, the toggle renders as a button
  • "search_form" (associative array) (default: predefined structure): ECL Search Form component structure
  • "notification" (object) (default: {}): Optional notification compatible with ECL Notification component structure
  • "extra_classes" (optional) (string) (default: '') Extra classes (space separated)
  • "extra_attributes" (optional) (array) (default: []) Extra attributes
    • "name" (string) Attribute name, eg. 'data-test'
    • "value" (string) Attribute value, eg: 'data-test-1'

Deprecated

  • "banner_top" (string) OR (object with Link component in property): Class name

Example :

{% include '@ecl/site-header/site-header.html.twig' with { 
  site_name: 'This site name'
  logo: {
    alt: 'European Commission', 
    href: '/example', 
    src: '/logo-ec--en.svg', 
  }, 
  language_selector: { 
    href: '/example', 
    label: 'English', 
    aria_label: 'Change language',
    code: 'en', 
    overlay: { 
      close_label: 'Close', 
      title: 'Select your language', 
      items: [ 
        { lang: 'bg', label: 'български', path: '/example#language_bg' }, 
        { lang: 'es', label: 'español', path: '/example#language_es', active: true }, 
        ... 
      ], 
    }, 
  },
  custom_action: { 
    href: '/notifications', 
    icon: 'bell', 
    label: 'Notifications', 
    aria_label: 'View notifications', 
    indicator: true, 
    overlay: { 
      title: 'Notifications', 
      close: { 
        label: 'Close' 
      }, 
      content: '<p>You have new notifications.</p>', 
    }, 
  }, 
  login_toggle: { 
    label_not_logged: 'Log in', 
    href_not_logged: '/example', 
    label_logged: 'Logged in', 
    href_logged: '/example', 
  }, 
  login_box: { 
    id: 'login-box-id', 
    description: 'Logged in as <last name>, <first name>', 
    label: 'Log out', 
    href: '/example', 
  }, 
  search_toggle: { 
    label: 'Search', 
    href: '#', 
  }, 
  search_form: { 
    text_input: { 
      id: 'input-search', 
      name: 'search', 
    }, 
    button: { 
      label: 'Search', 
    }, 
  }, 
  extra_classes: 'my-extra-class-1 my-extra-class-2', 
  extra_attributes: [ 
    { name: 'data-test', value: 'data-test-value' }, 
    { name: 'data-test-1', value: 'data-test-value-1' }, 
    ... 
  ], 
} %} 

版本与发布记录

@ecl/site-header 共发布 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/site-header 的常见问题

@ecl/site-header 是什么?

ECL Site Header

如何安装 @ecl/site-header?

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

@ecl/site-header 支持 TypeScript 吗?

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

@ecl/site-header 支持 ESM 还是 CommonJS?

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

@ecl/site-header 可以商用吗?

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

@ecl/site-header 的下载量有多少?

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

@ecl/site-header 还在维护吗?

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