How do I add a class to a specific input type? Using Drupal 8. I am trying to add class="input" to an input with type="text"; any other type (i.e type="button") should not have that class added. I modified input.html.twig to the following:

&lt;input{{ attributes.addClass('input') }}/&gt;{{ children }}


The problem with this is that it adds the class to all input types. Is there a way to specify the input type in which the class should be added in Drupal 8?
Template files are available by default for each input type.


Copy the input.html.twig file and rename it input--textfield.html.twig
Put it in the folder of the theme
Clear the cache and the new template will be used for all text-field form fields
You can add &lt;input{{ attributes.addClass('input') }}/&gt;{{ children }} in that file


If you want a more customized input field, you implement hook_theme_suggestions_HOOK().

function YOUR_THEME_NAME_theme_suggestions_input_alter(array &amp;$suggestions, array $variables) {
  // To see available variables use kint().
  kint($variables);
  if ($variables['element']['#type'] == 'textfield' &amp;&amp; $variables['element']['#name'] == field__--------- ) {
    $suggestions[] = 'input__customized';
  }
}