Add specific CSS class to form elements from the address field I try to add a custom css class to a form element inside my address field for e.g the postal_code field and another class to the given_name and family_name field.

I tried it with a my_theme_theme_suggestions_form_element_alter. But then I have to extend all the twig files like form-element--equal-width-column.html.twig, for just adding the css class.

function my_theme_theme_suggestions_form_element_alter(array &amp;$suggestions, array $variables, $hook) {

  if (in_array($variables['element']['#attributes']['class']['0'], ['family-name', 'given-name'])) {
    $suggestions[] = $hook . '__equal_width_column';
  }
}


Is it possible to just add a css class to specific form-elements div's, so I don't have to extend all those twig files?
You can use the hook_form_FORMID_alter in order to add classes to the fields you want to.

/**
* Implements hook_form_FORM_ID_alter();
*/
function hook_form_FORM_ID_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['my_custom_field']['#attributes']['classe'][] = "my-custom-class"
}