Note: Before I post this in theme components, I wanted to get some feedback first if this theme component qualifies or if there are any major issues with it.
Disclosure: This theme component was planned, implemented, and tested with the help of AI coding tools.
Discourse Tag Reveal is a lightweight theme component that keeps topic lists tidy by showing only the first N tags per topic and replacing the rest with an accessible “+X more tags” toggle. Users can expand to see all tags and collapse back to the shortened view. It works out of the box with Discourse’s standard tag UI and requires no server-side changes.
Features
Configurable tag limit (default: 5) via theme settings
Toggle styled as a tag, keyboard accessible (Enter/Space) with ARIA attributes
Localized strings using themePrefix and discourse-i18n
SPA-safe behavior: resets and re-applies logic on page changes
Supports infinite scrolling via MutationObserver
Minimal CSS; respects core tag styles
No template overrides or plugin dependencies
Video Demo:
Installation & Configuration
Tested with Discourse version: 3.6.0beta1
Configure settings under the component’s Settings tab:
max_tags_visible (integer, default 5): How many tags to show before collapsing
toggle_tag_style : Visual style of the toggle to match tag appearance (Currently only “box” style implemented)
Added a quick video demo in the first post, see here:
I haven’t even checked how to submit/add my TC component there…
But either way, I prefer to gather some feedback here first, and once it’s ready to be published in Theme component, I will see how to add it there.
good point. I forgot to change the default label to +%{count} more to keep it short and concise, that’s how we use it and keep things compact and clean.
This feature could be interesting in some situations!
At first glance, there are a few things to note:
Theme settings and Site settings are not the same. You need to retrieve the service first to access max_tags_per_topic, e.g.: const siteSettings = api.container.lookup("service:site-settings");
The extra checks to get the limit should not be necessary; you can retrieve the value directly. You can probably do Math.min(settings.max_tags_visible, siteSettings.max_tags_per_topic )
You are not restoring the visibility of separators.
You might want to unregister the events
The process on initial load should not be needed with MutationObserver. Usually, before going global, you would want to check first if there is a way to reduce the scope around the element using the API (plugin outlet, for example).