The application provides bundled skins and the ability to add custom skins. This document describes the interplay between bundled skins and building your own look and feel.
A skin is a set of styles, similar to cascading style sheet classes, that configures the user interface colours, fonts, spacing, highlights, drop-shadows, gradients, and more.
For more information on CSS, see the W3C CSS tutorial.
The order that stylesheets are applied matters so that stylesheets can override styles defined previously. The application's user interface is made up of the following stylesheets, applied in the order listed:
- scene.css --- Defines toolbar styling.
- markdown.css --- Defines text editor styling.
- skins/skin_name.css --- Bundled skin selected in preferences.
- custom.css --- User-defined file set in preferences.
Create a custom skin as follows:
- Start the application.
- Click File → New to create a new file.
- Click File → Save As to rename the file.
- Save the file as
custom.css
. - Change the content to the following:
.root {
-fx-base: rgb( 30, 30, 30 );
-fx-background: -fx-base;
}
Next, apply the skin as follows:
- Click Edit → Preferences to open the preferences dialog.
- Click Skins to view the available options.
- Click Browse to select a custom file.
- Browse to and select
custom.css
, created previously. - Click Open.
- Click Apply.
The user interface immediately changes to a dark mode. Continue:
- Click OK to close the dialog.
- Change the rgb numbers in custom.css from
30
to60
. - Click File → Save to save the CSS file.
The user interface immediately changes colour.
When creating your own skin, there many classes that can be styled. The previous section showed how to set up a rudimentary skin. Instead, start with a template that already has a number of classes defined so that you can tweak them to your taste. Accomplish this as follows:
- Visit the skin repository directory
- Click one of the files (e.g.,
haunted_grey.css
). - Click Raw.
- Copy the entire text.
- Return to
custom.css
. - Delete the contents.
- Paste the copied text.
- Save the file.
To see how the CSS styles are applied to the text editor, open markdown.css, which is also in the repository.
The basic look used by the application is Modena Light. Typically we only need to override a few classes to completely change the application's look and feel. For a full listing of available styles see the OpenJDK's Modena CSS file.
The Java CSS Reference Guide is exhaustive. In addition to showing many differences between JavaFX CSS and W3C CSS, the guide introduces numerous helpful functions for manipulating colours and gradients using existing colour definitions.
The application uses RichTextFX to render the text editor. Styling various
text editor classes can require using the prefix -rtfx
instead of the
regular JavaFX -fx
.
If you have a look that you'd like to contribute to the project, do pass it along. Either open a new issue in the issue tracker that contains the CSS file or submit a pull request.