This article from InSource shows how to leverage Cascading Style Sheets in j5
- Author: Ron Tanner
- Published: 06/27/2022
- Applies to: j5 2019
Using Cascading Style Sheets in j5
Cascading Style Sheets (CSS files) can be added in different locations to affect different levels of a j5 system. The location determines where the rules will be applied in the system.
To apply a CSS to all field labels the entire j5 site to a particular color you would add a site.css file to the project root. The contents would be as follows:
With the use of CSS classes in the site.css file you can apply CSS more specifically.
Specific selectors will override general selectors.
- A selector at the module level will be more specific than a matching one at a site level
- A selector with a CSS class component (example: Label.important) will be more specific than one without (example: Label)
Example: adding a module.css file to the Organization module.
The result of the logbooks in this module:
Adding a CSS file to the logbook (logbook.css) should be located at the same level as the logbook.yml file.
Adding the tag to the specific field(s):
Adding the logbook.css file at the same level as the logbook.yml file:
The logbook.css file:
You can also add colors to field options:
There is an option to apply colors to the field options in the logbook list view (grid view).
Example: colors can be added to a select type field and this will then be applied and displayed in the grid view.