Header Search

:discourse2: Summary Header Search removes the search icon from the header menu and creates a search bar that is placed in the middle of the header area.
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-header-search
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Features

Settings

Name Description
extra search icons Add extra icons to the search bar (for example to trigger an external search).
svg icons

Optionally show external search icons

Use the extra_search_icons to show additional icons in the search bar.

This setting supports the following params:

  • prefix: the prefix to the search URL when clicking the respective icon
  • icon: icon to show, from the Font Awesome set (may need to be added to the svg icons setting as well)
  • target: optionally set to “_blank” to open the link in its own tab/window by default
  • showInCategories: category IDs where the given icon should be shown exclusively (by default, icon is shown everywhere)
  • excludeFromCategories: category IDs where the given icon should not be shown

Credits

Thanks to @Johani for the search panel javascript code :+1:


:discourse2: Hosted by us? Theme components are available to use on our Standard, Business, and Enterprise plans.

Last edited by @JammyDodger 2024-06-12T21:32:41Z

Check documentPerform check on document:
36 Likes

I’ve just made an update to the component, this will make the default search icon appear on mobile:

6 Likes

This works fine now .

:kissing_heart: @JammyDodger

:kissing_heart: @awesomerobot

Thanks.

5 Likes

Hello, first of all really good theme component. Works very well for me.
I have a small suggestion for improvement. The search bar should certainly not be displayed in a login-required forum, since it can not be used anyway.

4 Likes

I would be very happy if someone can fix this bug. I know it doesn’t affect many, but I love this theme component and this problem keeps me from using it :cry:

1 Like

I’ve just made an update that will hide the search bar from logged out users when login is required

3 Likes

I’ve also added an update that uses the header colors (header primary and header background) for the input

4 Likes

The component seems to disable the new header-sidebar-toggle.

4 Likes

Thanks for identifying this @nolo!

I’ve just pushed out a fix :tada:

6 Likes

Another small glitch I came across: I can use the default “/” shortcut to enter the search input field. But it won’t expand the drop-down showing results. I’d need to click in the input field manually for that to happen which makes the keyboard shortcut kind of useless.

1 Like

Using the component disables the header-sidebar-toggle again. I guess it’s because the settings for the sidebar changed.

2 Likes

This should be fixed with this latest PR FIX: Refactor to include sidebar toggle by jordanvidrine · Pull Request #12 · discourse/discourse-header-search · GitHub

3 Likes

@jordan-vidrine Hi, can i use this component as default in mobile header

1 Like

I had considered this before releasing, but there isn’t enough room in the mobile header for this to work properly.

4 Likes

Thank you for the great component.

Is there a way to customize the color of the border of the search box?

Screenshot from 2023-03-02 10-13-59

For me it is kind of grey, I’d love for it to be #FFFFFF white

2 Likes

You can customize this color by adding some css to a local theme-component if you have one you’ve created for adding custom css.

If you havent done this, visit /admin/customize/themes and click on components, then install.

When the modal pops up, select to Create New, then name your component. You will be taken to the component’s new page where you can select the theme to apply it to. You will want to apply it to the installed theme.

To add the css, click on Edit CSS/HTML and add the css to the common page and save.

You will want to do something like this:

.search-menu .search-input {
    border: 1px solid #FFFFFF
}
2 Likes

Thank you @jordan-vidrine for the detailed instructions.

I had recently already learned with help from other good people on this forum to add custom CSS.

3 Likes

This might be of some help for further modifications :slight_smile:
https://meta.discourse.org/t/make-css-changes-on-your-site/168101#how-do-i-find-which-selectors-to-use-6
It explains how to find which element to target with CSS.

4 Likes

Can I remove that line and use media queries to disable it until 768px without breaking everything? :slight_smile:

I like to remove the button (because we have chats and video there) on tablet and I see the search box fit’s really OK.

1 Like

Everything is fine, but in the mobile version you need to switch to the standard search, because it looks terrible
image
vs
image

1 Like