Field formatter attributes
This module allows administrators to add custom HTML attributes to the wrapper elements of fields in Drupal's display settings and Layout Builder. It provides an easy way to modify the HTML output without needing to create custom Twig templates for every field.
This module allows site administrators to add additional HTML attributes to the wrapping markup on any field in the Manage Display settings page and in Layout Builder.
Instructions
The field formatter attributes settings are found in the Manage display tab for content types, users, and other entities. A options element is available for each field formatter, revealed by using the formatter settings edit button (Gear wheel icon) for that field.
Finally copy the field.html.twig file into your theme to allow access to all features. Or make your existing template compatible.
Dependencies
No dependencies outside of Drupal core. There is however a field.html.twig file which is recommended for use with this module. It is a drop-in replacement for the core provided template.
Related projects
This module is based on the Field Formatter Class module. It has simply been extended to allow arbitrary attribute name/values to be added.