# Add per-user CSS in a plugin?

**URL:** https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962
**Category:** Development
**Created:** [August 9, 2025, 4:42am UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962 "2025-08-09T04:42:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [August 9, 2025, 4:42am UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962/1 "2025-08-09T04:42:15Z")

</div>

In a plugin, how does one add a per-user CSS? E.g. caused by a user setting?

Adding the styles and whatnot to elements/via stylesheets would be global, no?

---

<div class="post-metadata">

### Author: ![Kartoon](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@Kartoon](https://meta.discourse.org/u/Kartoon)
#### Post date: [August 9, 2025, 6:39am UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962/2 "2025-08-09T06:39:05Z")

</div>

What are you trying to do? You can do things like change individual username/mention color just through the normal theme CSS. If you mean like, change some specific part of a theme with a toggle through a specific users preferences I don’t believe you could do that without giving them their own theme. I’m no expert though

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [August 9, 2025, 8:44am UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962/3 "2025-08-09T08:44:11Z")

</div>

Like for example, a per-user setting to change fonts of certain things (e.g. the Markdown composer).

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [August 9, 2025, 8:50am UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962/4 "2025-08-09T08:50:23Z")

</div>

You could offer groups that the user can join and use [CSS Classes for Current User's Groups](https://meta.discourse.org/t/css-classes-for-current-users-groups/226068).

Or the user can use a browser plugin to change CSS only for themselves. I use Stylus to customize my experience on Meta.

Was the composer a random example? Or what do you want to offer in addition to “Use monospace font in composer’s Markdown mode,” which can be enabled or disabled in the preferences?

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [August 9, 2025, 9:04am UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962/5 "2025-08-09T09:04:55Z")

</div>

> [@Moin](#):
>
> Was the composer a random example?

Kinda. I was thinking how the font would be changed per-user.

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [August 11, 2025, 11:20pm UTC](https://meta.discourse.org/t/add-per-user-css-in-a-plugin/377962/6 "2025-08-11T23:20:27Z")

</div>

You can probably achieve this in a plugin by doing something along the lines of:

- with the plugin API add a [`api.addSaveableUserOptionField("composer-custom-font")`](https://github.com/discourse/discourse/blob/3ab8e66c00cfd89890cf57275ff1777f85ec2c86/app/assets/javascripts/discourse/app/lib/plugin-api.gjs#L2318-L2320)
- add the field to the `UserOption` table in the db and the serializer so it can be set
- add a connector to the user’s interface page so the setting can be set
- you can make the setting a dropdown, for example, so if the user picks a certain font/font style it adds their preference in the db
- you can extend the composer code to take into account their selected preference, and either change the styles directly with JS or make it add a CSS class based on the preference chosen, which you can apply styles via CSS for that specific class
