Header Categories Navbar

:discourse2: Summary Header Categories Navbar is a simple component that adds a menu of parent category links to the site header, with horizontally scrolling overflow added if/when needed.
:eyeglasses: Preview Preview on Theme Creator
:hammer_and_wrench: Repository https://github.com/discourse/discourse-categories-navbar
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Features

This theme component adds a menu of parent category links to the site header:

Settings

Name Description
hide category dropdown Hides category dropdown from topic list navigation
hide all breadcrumb nav Hides all breadcrumbs from topic list navigation
hide on topic scroll When enabled, the nav will be hidden on desktop when the topic title is docked to the header

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

Last edited by @JammyDodger 2024-07-26T10:44:50Z

Last checked by @JammyDodger 2024-06-07T21:29:01Z

Check documentPerform check on document:
20 Likes

This is really cool - I love it, Kris! It will combine with the sidebar beautifully, allowing the core cats up top and a short personalised selection on the bar.

I’ve noticed two little UX issues that could really give it a lift if addressed:

UX: Category selection highlight

When on a category list, the correct category has a lovely subtle underline.

However, this doesn’t persist if a Topic or a subcategory is entered.

It would be lovely if it did persist in both of those situations.

UX: scroll / overflow on mobile

There is a nice little fade / subtle arrow visible when there is overflow of the categories on desktop.

Overflow is much more likely on mobile, but on my device (Chrome / Android) these subtle cues are not present - and it isn’t clear that scrolling is possible.

It might also help to have the categories bar a little taller on mobile to make scrolling easier.

6 Likes

Another couple of UX issues on mostly applying to mobile:

Mobile topic breadcrumb clash

In mobile topic views, the breadcrumb navigation clashes with the categories navbar:

Highlighted category not in view

Also, the category selected isn’t scrolled to automatically - this means that it is not apparent that it is selected unless the user scrolls the Navbar. This is vital really.

Desktop only?

I do wonder if it isn’t really ready for mobile yet, and it would be really handy to have a setting to only apply it to desktop (at least for now).

4 Likes

Thanks for the quick feedback! I’ve merged in some updates that should address these.

3 Likes

Brilliant - very happy to give feedback when it is listened to! You’ve had to make quite a few additions to it I note.

I’ll take that as a nice little Christmas :gift: to one another :heart_eyes:.

You’ve fixed this when a Subcategory has been entered - wonderful!

However, it does not apply when a topic is entered - is that deliberate? Personally, I believe that it would make sense if the category stays highlighted while the user is ‘in’ it, which includes the topics and not just the category discovery views.

Also, when I enter another page (such as /admin) the category remains selected. It would be better if no category was selected in this case.

I can see the fade on mobile now, but not an arrow / chevron. If possible this would be super helpful as the fade is pretty damn subtle:

Desktop: image

Mobile: image

Request #1 - UX

Hide the Navbar when scrolling in a topic. It all gets a bit busy!

Also, it might be better on desktop to have the Navbar located where the breadcrumb / tags are in that image instead of below them.

Request #2 - Feature

Could you please add a CSS class to each Nav Pill so it would be easy to hide some if needed?

I ask because I have a couple of (private) parent categories which are only parents in order to enable subcategories, and they clutter up the general navigation in an undesirable way.

I’ve hidden these for now using their href, but that is of course pretty dicey!

Request #3 - UX

An option to sort Sidebar Categories alphabetically.

As I’m implementing this, I’ve removed the parent categories from the default sidebar categories list. This means that my users now have just a list of 1-5 subcategories that are relevant to them.

However, they are a bit scrambled and in no logical order as the order on /Categories for subs doesn’t really make sense . It would be very helpful for these subcats to be alphabetic to help this!!

4 Likes

Colors are bit off when selected

  • default light and dark palettes

Ideas?

3 Likes

Thanks for reporting! this should fix it:

2 Likes

Works perfectly. Thanks!

2 Likes

Hello! First of all, I would like to note that this is a very useful component of the topic and I want to thank you for the work you have done :raised_hands:
On my instance, this component caused an error, I checked for compatibility with other plugins and theme components and at this point I have not yet found a conflict. Could the component itself be the cause?

Enabling this component distorts the presentation of the content.
Here’s a video:


In order to detect an error, you need to click on any post from the latest posts page /latest, the post will open in standard mode, then you need to go back to the latest posts page.

1 Like

@Aizada_M - I can’t seem to reproduce this. Is this happening to you when you preview from the component?

2 Likes

Greetings! Sorry for the long response :raised_hands:
I didn’t use the preview, I tested it with the component enabled.

1 Like

This works 100% of the time when I click on the category name under the topic title.

1 Like

I’ve noticed that the text in the Head Categories Navbar suddenly changed to font-up-1 (whereas I think it was font-down-1 before). This is quite jarring and unpleasant, as it is the same as all the other nav pills.

I’ve over-ridden it with this CSS, which is much more pleasing:

// fixes text size of header navbar
.custom-categories-navbar .nav-pills>li>a {
    font-size: var(--font-0);
}

I prefer font-0 actually as it is different enough and a bit easier to use.

1 Like

The core CSS did not change, and the component does not set the font size. :thinking:
Maybe you had custom CSS before?

2 Likes

4 posts were split to a new topic: Broken mobile styling of Header Categories Navbar

Love this TC, thank you! Would be great to customize which items do and do not appear!

3 Likes

I love it but the theme component seems broken in the latest version of discourse

EDIT: it’s works fine, but needed to desactive “chat” and “Dark-Light Toggle” icons in the header

2 Likes

It works for me with chat active :slight_smile:

3 Likes

yes it’s because of my logo. If i cut it a little bit, its works with chat and dark-light toggle. I"m using:

.d-header #site-logo {
max-height: 30px;
}

for now

2 Likes

Hey, i just saw a bug now, you can reproduce like that. On mobile:

1- Click on one category in the header
2 - Click on one post in the category and Scroll at the end
3 - Click on the same category on the header

All the category header will disappear. I just tryed it on my forum and on the demo

EDIT:

it’s the same if you go to a category and refresh( f5) the page. All category will disappear.

EDIT:

Is there any fix for it? Thanks

4 Likes