Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Entity Class Formatter

Security covered Under active development 5,725 sites

Part of the Entity ecosystem · 308 projects

This module allows you to format field values to add custom classes or attributes to the parent entity. This can then be used to modify the entity's appearance through CSS or other theming tools. It supports various field types and all entity types.

Overview

Entity Class Formatter is a very simple module which formats values of fields (of varying types) such that a class or attribute is placed on the parent entity of that field. The module can be used to apply classes/attributes on entities, allowing the class/attribute to act as a modifier which can be used by the theming layer.

Usage

Follow these steps

  • Add a text, list, entity reference or boolean field to any entity (Node, Paragraph, Block, etc).
  • Set the display to "Entity Class" (on manage display admin page).
  • Create matching CSS rules in your theme or map a Modifier using the Look module.

Optional configuration

  • Prefix to be attached before each class/attribute.
  • Suffix to be attached after each class/attribute.
  • Attribute name to be used instead of class.
  • Referenced entity field name to be used instead of label.

Supported field types

This formatter can be applied to the following field types:

  • Text
  • List
  • Entity Reference
  • Boolean

Supported entity types

This formatter works with all entity types.

Similar Modules

The module is similar to two other modules, but differs in important ways.

The Classy Paragraphs module was intended to apply to Paragraphs only and is quite structured in the way classes are applied through a custom field type. The Entity Class Formatter module is more flexible in that it has been designed to apply to all entity types. It can also handle a variety of field types (text, select lists, entity references) and is able to adapt to the data at hand.

The Field Formatter CSS Class module also uses a field formatter approach to applying the class to the entity. It does have more complexity than this module because it deals with several layers of nesting. The Entity Class Formatter is very simple and only applies to the parent entity of the field.

Demo Video

Drupal Modules: The One Percent —Entity Class Formatter (tutorial) from NonProfit.

GitHub

Development is happening in our GitHub repository. The drupal.org issue queue is still used to coordinate development.

Drupal 9–11

Ask your assistant about Entity Class Formatter

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • field Drupal core

Required by

1 tracked project depends on this one

Activity

Tracked releases
3
Tracked since
Feb 2023
Latest release
2 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.0.2 Stable 9–11 Jul 21, 2026
2.0.1 Stable 9–11 Sep 30, 2024
2.0.x-dev Dev 9–11 Feb 12, 2023