A module can define field type categories in a MODULE_NAME.field_type_categories.yml file contained in the module's base directory.
Each plugin has the following structure:
CATEGORY_NAME:
label: STRING
description: STRING
weight: INTEGER
libraries:
- STRING
Setting the field type category as a translatable label in annotation is deprecated:
Before
/**
* @FieldType(
* id = "decimal",
* label = @Translation("Number (decimal)"),
* ...
* category = @Translation("Number"),
* )
*/
class DecimalItem extends NumericItemBase { ... }
After
/**
* @FieldType(
* id = "decimal",
* label = @Translation("Number (decimal)"),
* ...
* category = "number",
* )
*/
class DecimalItem extends NumericItemBase { ... }
Where number is the category ID defined in core.field_type_categories.yml:
...
number:
label: 'Number'
description: 'Field to store number. I.e. id, price, or quantity.'
weight: -40
libraries:
- module_name/library_name
...
The library allows loading assets within the Field UI when the categories are displayed. This allows the category to provide an icon for itself:
.field-icon-number {
background-image: url("...");
}

BC layer
Your module can add a backwards compatibility layer for Drupal 10.1 and previous versions by adding the following hook implementation to your .module file.
use Drupal\Core\StringTranslation\TranslatableMarkup;
// ...
/**
* Implements hook_field_info_alter().
*
* @todo Remove once minimum version supported is at least 10.2.0.
*/
function MODULE_NAME_field_info_alter(array &$info): void {
// Allow module to work with versions of older versions of Drupal.
if (\version_compare(\Drupal::VERSION, '10.1.9999', '<')) {
// @todo Replace 'decimal' with the field type and "Number" with the previous category string.
$info['decimal']['category'] = new TranslatableMarkup("Number");
}
}
The field type category info can be accessed with the help of the plugin methods getLabel(), getDescription(), and getWeight(), etc. These methods are available on the plugin instances retrieved using the YAML-based plugin discovery system.
Comments
Can someone confirm if field
Can someone confirm if field categories are only fetched from enabled modules. My reading of the core code seems to say yes.
The implication is that if this method for field type categories is being used, then the modules providing them should be added to the composer.json and .info.yml files of those other modules that might want to use the categories.
http://SocialNicheGuru.com
Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.