Change record status: 
Project: 
Introduced in branch: 
8.8.x
Introduced in version: 
8.8.0
Description: 

While hook_element_info_alter has long provided a way to change the defaults of a render element, in Drupal 8 elements are now plugins and swapping the plugin class itself was not possible before. A new hook has been added for this purpose: hook_element_plugin_alter(array &$definitions). The argument are the definition arrays of element plugins so for example:

function mymodule_element_plugin_alter(array &$definitions) {
  // Use a custom class for the LayoutBuilder element.
  $definitions['layout_builder']['class'] = \Drupal\mymodule\Element\MyLayoutBuilderElement::class;
}
Impacts: 
Module developers