You are here

Drupal 8

How to make search block form label visible - Drupal 8

By default, the label for the search form text input in Drupal 8 is set to invisible, that is, it's present but hidden by applying the "visually-hidden" class so users of assistive technology can still read it. But what if you want to display it visually?

That's not so easy. There's no way to do it through configuration, and little to no information about how to do it with code.

I muddled around and finally found where the visibility was being set, in SearchBlockForm.php in the core Search module. In there we find:

Truncated expanding text field with "show more" link in Drupal 8 & Twig

I've been working on a website with the requirement to truncate certain text fields—display the first several words of the text, with a "show more" link which on click, expands the rest of the text.

As I was under a very tight deadline, I found and implemented a jQuery plugin that did what I needed. Quick and easy.