Active
Project:
Drupal core
Version:
main
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 Mar 2026 at 14:58 UTC
Updated:
9 Mar 2026 at 15:30 UTC
Jump to comment: Most recent
#3559156: Support Twig's CVA function added Twig's html-extra package to core, which introduces a few additional helpful functions. One of them is html_classes: https://twig.symfony.com/doc/3.x/functions/html_classes.html
The function is already available, maybe we can use this to partially clean up some of our Twig templates.
Comments
Comment #2
longwaveOur current pattern is to prefer handling all attributes in one go, where I don't think this will help. As an example, Claro's details element does this:
However, there are a handful of places where we do construct class lists directly that could be improved slightly:
In Claro's system-themes-page we do have a slightly awkward usage of createAttribute() that appears to double the ID attribute: