Add a class the the form element (tag) of the search block form How do I add a class to the form element of the search block form?

I mean, add a class to this element:

&lt;form action="/search/node" method="get" id="search-block-form" accept-charset="UTF-8" data-drupal-form-fields="edit-keys"&gt;&lt;/form&gt;


I've tried:

function mytheme_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    $form['#attributes'] = array('class' =&gt; array('abc'));
  }
}


and

function mytheme_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    $form['#attributes']['class'][] = 'abc';
  }
}


I've tried:

function mytheme_preprocess_form(&amp;$variables) {
  if ($variables['element']['#form_id'] == 'search_block_form') {
    $variables['element']['#attributes'] = array('class' =&gt; array('xyz'));
  }
}


I've looked into altering core/modules/system/templates/form.html.twig, which does not look like the way to go.

I'm using the Bootstrap theme as my base.
you can use the prefix and suffix tag
like

$variables['element']= ['#prefix' =&gt; '&lt;div class ="abc"&gt;',
                        '#suffix' =&gt; '&lt;/div&gt;']