Skip to main content
  • Guides & Documentation

Knowledgebase

Featured articles, how-to guides and quick tips.

Theming all Fields in a Paragraph (Quickly) - Drupal 8

You might need to quickly theme all fields in a specific paragraph you've created using the Paragraphs module for Drupal 8.

A possible use case for this could be if you have multiple image fields in a Paragraph, but don't want to theme the fields for each individual field.

For example, if you have 20 different image fields in one Paragraph, and aren't using multiple items for one specific field, it might be quite challenging to theme each field individually.

This is particularly the case if you have multiple fields which require the same styling or theming. There's no need to force Drupal to sift through so many files, and there is just as little need for you to write them all.

The trick is in the naming convention of your field template file.

You can theme all of the fields for the paragraph type at once, using a file name convention that follows this pattern:

field--paragraph--[paragraph-type-machine-name].html.twig

Apply your field theming here, save the file, and clear all Drupal caches.

If you've named the file appropriately, you'll find all fields within it are now using your new template. Fancy!

If you then need to field an individual field a little further, you can use this naming convention:

field--paragraph--[field-machine-name]--[paragraph-type-machine-name].html.twig

Happy theming!