Skip to content

Instantly share code, notes, and snippets.

@mherchel
Last active November 2, 2022 12:34
Show Gist options
  • Save mherchel/57533351d9efdb2905ec106b2a007421 to your computer and use it in GitHub Desktop.
Save mherchel/57533351d9efdb2905ec106b2a007421 to your computer and use it in GitHub Desktop.
{# field--details.html.twig #}
{%
set classes = [
'details-item',
'details-item-' ~ field_name|clean_class,
]
%}
<details{{ attributes.addClass(classes) }}>
<summary{{ title_attributes }}>{{ label }}</summary>
<div class="details-item__content">
{% for item in items %}
<div{{ item.attributes.addClass('details-item__content-item') }}>{{ item.content }}</div>
{% endfor %}
</div>
</details>
{{ content.field_items|add_suggestion(‘details’)|setAttribute('open', 'open') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment