I’ve created a theme but I don’t really want it to be usable by normal users.
Can I use a theme without selecting " Theme can be selected by users" ? (I’m an admin.)
The discussion revolves around using a custom theme without making it available to normal users. TheTechRobo wants to use a theme they created as the main theme for themselves, without selecting the “Theme can be selected by users” option.
Simon suggests that using the preview option is not a solution, as it will revert to the normal theme without the preview option in the URL.
Awesomerobot proposes using CSS to target admins and moderators with a custom theme, but this would still require listing the theme as available. They also suggest using a plugin outlet or template overrides to achieve this.
However, TheTechRobo clarifies that their theme only uses a color palette and not CSS, and that listing the theme as available is not an option.
Awesomerobot suggests alternative solutions, including overriding the color scheme with CSS, building a custom plugin, or using a browser plugin like Stylish to set custom CSS locally.
I’ve created a theme but I don’t really want it to be usable by normal users.
Can I use a theme without selecting " Theme can be selected by users" ? (I’m an admin.)
I meant as the main theme, i.e. the main theme for me. Not just previewing, as previewing will go back to normal without the preview option in the URL
Admins and moderators have the .staff class assigned to the page body, so you could do something like this in a theme:
body.staff {
// your admin theme's css here
}
A normal user could add the class staff to their body tag (via the browser inspector) and see the theme too, but I’m not sure why anyone would bother trying that.
For more advanced themes, if you’re using a plugin outlet or changing html with template overrides (see Developer’s guide to Discourse Themes) you can do something like this:
{{#if currentUser.staff}}
<h1>hello admins and moderators!</h1>
{{/if}}
a) I do not use any CSS in my theme - simply a colour palette.
b) That would still require listing the theme as available.
You can override the color scheme with CSS (some detail here: Update themes and plugins to support automatic dark mode), otherwise you’d need to build a custom plugin to allow you to set a different theme for an admin, as it’s not an existing feature within Discourse.
The idea would be to put the admin CSS in your default theme; unless someone went digging around in your CSS you’d be the only one to see/utilize it.
Another option entirely is to use a browser plugin like stylish to set custom CSS locally.