Theming forms. Form-element Please, help. Is it possible implement different templates for form-element.html.twig? For form 'user-form' one template, and for other forms second template.
As you requested, this is an example how I did using field names.

In your .theme file:

function THEME_preprocess_form_element(&amp;$variables) {
  //This is a list of fields in contact form
  $showAfter = array('name', 'mail', 'subject[0][value]', 'message[0][value]');
  if (in_array($variables['name'], $showAfter)) {
    //If is one, I change here how to display instead using different twig file
    $variables['element']['#title_display'] = 'after';
    $variables['label_display'] = 'after';
  }
}


Now, if you want use different twig file for each field name use this...

.theme file

function THEME_theme_suggestions_form_element_alter(array &amp;$suggestions, array $variables, $hook) {
  if (isset($variables['element']['#name'])) {
    //Name can be a string like this, 'subject[0][value]'.
    //When this happen, I just get 'subject'.
    $suggestions[] = 'form_element__' . explode("[", $variables['element']['#name'])[0];
  }
}


Then in your HTML appear something like this:

&lt;!-- FILE NAME SUGGESTIONS:
   * form-element--subject.html.twig
   x form-element.html.twig
--&gt;


Note:
The main problem is how you get form_id in preprocess or theme_suggestions (form_element Hook), I didn't find a way to get this information.