Advanced Header Search

:discourse2: Summary Advanced 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

:white_exclamation_mark:Note

This theme component is only required when sites want to support external searches. Otherwise, you may update the Search experience setting to Search field in site header to move site search to the header.

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 @lindsey 2025-02-28T14:39:07Z

Check documentPerform check on document:
37개의 좋아요

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

https://github.com/discourse/discourse-header-search/commit/fb0969b04e564805ad2832bfa70e5ecdcb62daef

6개의 좋아요

This works fine now .

:kissing_heart: @JammyDodger

:kissing_heart: @awesomerobot

Thanks.

5개의 좋아요

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개의 좋아요

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개의 좋아요

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

https://github.com/discourse/discourse-header-search/pull/8

3개의 좋아요

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

https://github.com/discourse/discourse-header-search/pull/9

4개의 좋아요

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

4개의 좋아요

Thanks for identifying this @manuel!

I’ve just pushed out a fix :tada:
https://github.com/discourse/discourse-header-search/commit/637b21e351bca7c134ef1f58b3d59e87fef93f34

6개의 좋아요

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개의 좋아요

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

3개의 좋아요

This should be fixed with this latest PR https://github.com/discourse/discourse-header-search/pull/12

3개의 좋아요

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

1개의 좋아요

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

4개의 좋아요

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개의 좋아요

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개의 좋아요

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개의 좋아요

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개의 좋아요

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개의 좋아요

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

1개의 좋아요