How can I theme the Bootstrap base theme search block? I've created a sub-theme of the Drupal 8 Bootstrap base theme. My problem is that I'm using a customized version of the Bootstrap CSS Framework that does not include Glyphicons. Instead of Glyphicons, my project is using fontAwesome icons.  What I've realized though, is that the Bootstrap theme uses a Glyphicon Search Icon for the Search Form. Since I'm not using glyphicons and the CSS files are not included, I get a search form button that looks like this.


  


It should appear like this.


  


If i inspect the HTML markup using my browser, my theory is correct.

&lt;button type="submit" value="Search" class="button js-form-submit form-submit btn-primary btn icon-only" name=""&gt;&lt;span class="sr-only"&gt;Search&lt;/span&gt;&lt;span class="icon glyphicon glyphicon-search" aria-hidden="true"&gt;&lt;/span&gt;&lt;/button&gt;


if I change the following markup, the button shows up correctly because it can find the icon.

 &lt;span class="icon glyphicon glypicon-search"&gt;&lt;/span&gt; to &lt;span class="fa fa-search"&gt;&lt;/span&gt;


What I want to do is to be able to change the icon or the code in the base theme that generates this snippet of code.

&lt;span class="icon glyphicon glypicon-search"&gt;&lt;/span&gt; 


My assumption is that I should use a preprocess function to alter the form block and output/replace the Glyphicon span with the Fontawesome span.

I believe that the input--button.html.twig in the bootstrap base theme is responsible for outputting the icon classes because of this code.

{% block input %}
    {% if icon_only %}
      &lt;button{{ attributes.addClass(classes, 'icon-only') }}&gt;
        &lt;span class="sr-only"&gt;{{ label }}&lt;/span&gt;
        {{ icon }}
      &lt;/button&gt;
    {% else %}
      {% if icon_position == 'after' %}
        &lt;button{{ attributes.addClass(classes) }}&gt;{{ label }}{{ icon }}&lt;/button&gt;{{ children }}
      {% else %}
        &lt;button{{ attributes.addClass(classes) }}&gt;{{ icon }}{{ label }}&lt;/button&gt;{{ children }}
      {% endif %}
    {% endif %}
    {{ children }}
  {% endblock %}


Apparently, it is used to alter the button of many elements instead of only the search form.
Bootstrap theme is deeply bundled with glyphicons .. it guesses the icon from the button text.

You would need to override Bootstrap::glyphiconFromString() or Bootstrap::glyphicons(). I cannot tell you how to do this in your subtheme ...

If you removed the glyphicons, probably Theme::hasGlyphicons() will return FALSE and won't show any icon.

Workaround

You could replace the icon variable in template_preprocess_input, like:

function MY_TEME_preprocess_input(&amp;$variables) {
  if ($variables['icon']) {
    if (array_key_exists('glyphicon-search', $variables['icon']['#attributes']['class'])) {
     foreach($variables['icon']['#attributes']['class'] as &amp;$sValue)
     {
       if ($sValue == 'glyphicon') {
         $sValue = 'fa';
       }
       if ($sValue == 'glyphicon-search') {
         $sValue = 'fa-search';
       }
     }
    }
  }
}


or, I guess you have asked this question on do: https://www.drupal.org/node/2757463. There is a suggestion of overwriting the Input element:

Create a file at bootstrapsubtheme/src/Plugin/Preprocess/Input.php and add the following:

/**
 * @file
 * Contains \Drupal\bootstrapsubtheme\Plugin\Preprocess\Input.
 */

namespace Drupal\bootstrapsubtheme\Plugin\Preprocess;

use Drupal\bootstrap\Annotation\BootstrapPreprocess;
use Drupal\bootstrap\Utility\Variables;

/**
 * Pre-processes variables for the "input" theme hook.
 *
 * @ingroup theme_preprocess
 *
 * @BootstrapPreprocess("input")
 */
class Input extends \Drupal\bootstrap\Plugin\Preprocess\Input {

  /**
   * {@inheritdoc}
   */
  public function preprocessElement(Variables $variables, $hook, array $info) {
    $element = $variables-&gt;element;

    if ($element-&gt;icon) {
      $element-&gt;icon-&gt;replaceClass('glyphicon', 'fa');
      $element-&gt;icon-&gt;replaceClass('glyphicon-search', 'fa-search');
    }

    // Let bootstrap base theme preprocess the element normally now.
    parent::preprocessElement($variables, $hook, $info);
  }

}