How to add a theme suggestion to the textfield input based on the name of the view? I am using the following hook in a custom module:

MY_MODULE_theme_suggestions_input_alter(&amp;$suggestions, array $variables) {

  $suggestions[] = 'input_'. $element['#type']. '__'. 'form_id__' $element ['#form_id']. '__'. $element['#name'];
}


With which I get something similar (In my case I have an exposed filter using search api):

input-textfield-form-id-views-exposed-form-search-api-fulltext.html.twig


How can I get the suggestion in the following way?

input-textfiel--viewName--search-api-fulltext.html.twig


Where viewName is the name of the view from which the field is exported.

How can I access the view information from this hook?
If the View is displayed as a page, you can get the View ID from the current route parameters:

$view_id = \Drupal::routeMatch()-&gt;getParameter('view_id');
if ($view_id) {
  $suggestions[] = 'input_'. $element['#type']. '__'. $view_id . '__'. $element['#name'];
}


If it's a block, I can't think of a nice way to do it generically. One non-nice way would be to alter the form, and add a property to each element which can then be picked up in the suggestions hook. 

Something like this:

function MODULE_form_views_exposed_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  // You could check that the current display is a block here too if you need to
  $view_id = $form_state-&gt;getStorage()['view']-&gt;id();
  _MODULE_add_view_id_to_input_elements($form, $view_id);
}

function _MODULE_add_view_id_to_input_elements(array &amp;$root_element, $view_id) {
  $input_types = ['textfield', 'submit', '...'];

  if (in_array($root_element['#type'], $input_types)) {
    $root_element['#MODULE_view_id'] = $view_id;
  }

  foreach (\Drupal\Core\Render\Element::children($root_element) as $key) {
    _MODULE_add_view_id_to_input_elements($root_element[$key], $view_id);
  }
}


And then in the suggestions hook:

if (isset($element['#MODULE_view_id'])) {
  $suggestions[] = 'input_'. $element['#type'] . '__' . $element['#MODULE_view_id'] . '__'. $element['#name'];
}


This isn't particularly pleasant, but the exposed form elements themselves don't carry any context so you have to wedge it in there somehow I guess. Hopefully there's a cleaner method out there somewhere.