toolbar-button.html.twig

Same filename in other branches
  1. 11.x core/modules/navigation/templates/toolbar-button.html.twig
{# Extra classes variable added to be sure that modifiers will
appear after main classes #}
{%
  set classes = [
    'toolbar-button',
    icon ? 'toolbar-button--icon--' ~ icon : '',
    extra_classes,
  ]
%}
<{{html_tag|default('button')}}
  {{ attributes.addClass(classes) }}
  data-index-text="{{ text|first|lower }}"
  data-icon-text="{{- text|render|trim|slice(0, 2)|join('') -}}"
>
  {% if avatar %}
    <span class="toolbar-button__avatar">{{~ avatar ~}}</span>
  {% endif %}
  {% if action %}
    <span data-toolbar-action class="visually-hidden">{{ 'Extend'|t }}</span>
  {% endif %}
  {% block content %}
    {% if text %}
      <span class="toolbar-button__label {{ label_classes }}" data-text>{{~ text ~}}</span>
    {% endif %}
  {% endblock %}

  {# Element that improves sub-menu UX by implementing the Safe Triangle strategy.
More info at https://www.smashingmagazine.com/2023/08/better-context-menus-safe-triangles #}
  {% if has_safe_triangle %}
    <div data-toolbar-popover-safe-triangle></div>
  {% endif %}

</{{html_tag|default('button')}}>

File

core/modules/navigation/templates/toolbar-button.html.twig

View source
  1. {# Extra classes variable added to be sure that modifiers will
  2. appear after main classes #}
  3. {%
  4. set classes = [
  5. 'toolbar-button',
  6. icon ? 'toolbar-button--icon--' ~ icon : '',
  7. extra_classes,
  8. ]
  9. %}
  10. <{{html_tag|default('button')}}
  11. {{ attributes.addClass(classes) }}
  12. data-index-text="{{ text|first|lower }}"
  13. data-icon-text="{{- text|render|trim|slice(0, 2)|join('') -}}"
  14. >
  15. {% if avatar %}
  16. <span class="toolbar-button__avatar">{{~ avatar ~}}</span>
  17. {% endif %}
  18. {% if action %}
  19. <span data-toolbar-action class="visually-hidden">{{ 'Extend'|t }}</span>
  20. {% endif %}
  21. {% block content %}
  22. {% if text %}
  23. <span class="toolbar-button__label {{ label_classes }}" data-text>{{~ text ~}}</span>
  24. {% endif %}
  25. {% endblock %}
  26. {# Element that improves sub-menu UX by implementing the Safe Triangle strategy.
  27. More info at https://www.smashingmagazine.com/2023/08/better-context-menus-safe-triangles #}
  28. {% if has_safe_triangle %}
  29. <div data-toolbar-popover-safe-triangle></div>
  30. {% endif %}
  31. </{{html_tag|default('button')}}>

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.