Same filename in this branch
  1. 10 core/modules/system/templates/block--system-menu-block.html.twig
  2. 10 core/themes/olivero/templates/block/block--system-menu-block.html.twig
  3. 10 core/themes/stable9/templates/block/block--system-menu-block.html.twig
  4. 10 core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig
  5. 10 core/themes/claro/templates/classy/block/block--system-menu-block.html.twig
  6. 10 core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig
Same filename and directory in other branches
  1. 8.9.x core/modules/system/templates/block--system-menu-block.html.twig
  2. 9 core/modules/system/templates/block--system-menu-block.html.twig

Default theme implementation for a menu block.

Available variables:

  • plugin_id: The ID of the block implementation.
  • label: The configured label of the block if visible.
  • configuration: A list of the block's configuration values.
    • label: The configured label for the block.
    • label_display: The display settings for the label.
    • provider: The module or other provider that provided this block plugin.
    • Block plugin specific settings will also be stored here.
  • in_preview: Whether the plugin is being rendered in preview mode.
  • content: The content of this block.
  • attributes: HTML attributes for the containing element.
    • id: A valid HTML ID and guaranteed unique.
  • title_attributes: HTML attributes for the title element.
  • content_attributes: HTML attributes for the content element.
  • title_prefix: Additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • title_suffix: Additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

Headings should be used on navigation menus that consistently appear on multiple pages. When this menu block's label is configured to not be displayed, it is automatically made invisible using the 'visually-hidden' CSS class, which still keeps it visible for screen-readers and assistive technology. Headings allow screen-reader and keyboard only users to navigate to or skip the links. See http://juicystudio.com/article/screen-readers-display-none.php and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.

File

core/modules/system/templates/block--system-menu-block.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for a menu block.
  5. *
  6. * Available variables:
  7. * - plugin_id: The ID of the block implementation.
  8. * - label: The configured label of the block if visible.
  9. * - configuration: A list of the block's configuration values.
  10. * - label: The configured label for the block.
  11. * - label_display: The display settings for the label.
  12. * - provider: The module or other provider that provided this block plugin.
  13. * - Block plugin specific settings will also be stored here.
  14. * - in_preview: Whether the plugin is being rendered in preview mode.
  15. * - content: The content of this block.
  16. * - attributes: HTML attributes for the containing element.
  17. * - id: A valid HTML ID and guaranteed unique.
  18. * - title_attributes: HTML attributes for the title element.
  19. * - content_attributes: HTML attributes for the content element.
  20. * - title_prefix: Additional output populated by modules, intended to be
  21. * displayed in front of the main title tag that appears in the template.
  22. * - title_suffix: Additional output populated by modules, intended to be
  23. * displayed after the main title tag that appears in the template.
  24. *
  25. * Headings should be used on navigation menus that consistently appear on
  26. * multiple pages. When this menu block's label is configured to not be
  27. * displayed, it is automatically made invisible using the 'visually-hidden' CSS
  28. * class, which still keeps it visible for screen-readers and assistive
  29. * technology. Headings allow screen-reader and keyboard only users to navigate
  30. * to or skip the links.
  31. * See http://juicystudio.com/article/screen-readers-display-none.php and
  32. * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
  33. *
  34. * @ingroup themeable
  35. */
  36. #}
  37. {% set heading_id = attributes.id ~ '-menu'|clean_id %}
  38. <nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes|without('role', 'aria-labelledby') }}>
  39. {# Label. If not displayed, we still provide it for screen readers. #}
  40. {% if not configuration.label_display %}
  41. {% set title_attributes = title_attributes.addClass('visually-hidden') %}
  42. {% endif %}
  43. {{ title_prefix }}
  44. <h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
  45. {{ title_suffix }}
  46. {# Menu. #}
  47. {% block content %}
  48. {{ content }}
  49. {% endblock %}
  50. </nav>

Related topics