Add per-user CSS in a plugin?

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")
  • 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
2 Likes