Including Cascading Stylesheets in Themes for Confluence 2.6
Firstly, you will need to disable the inclusion of Confluence 2.5.x styles. These were included by default to allow 2.5.x themes to remain compatible in Confluence version 2.6 and after.
To disable 2.5.x styles, add the following to your theme's atlassian-plugin.xml
:
...
<theme key="aqua" i18n-name-key="com.atlassian.confluence.themes.aqua.name" name="Aqua Theme" class="com.atlassian.confluence.themes.BasicTheme">
<description key="com.atlassian.confluence.themes.aqua.desc"/>
...
<param name="includeClassicStyles" value="false"/>
...
</theme>
...
Note the flag includeClassicStyles
is set to false
. You will have to set this explicitly as the default is true
.
Secondly, you will need to declare your custom theme style sheet in atlassian-plugin.xml
like this:
...
<theme key="aqua" i18n-name-key="com.atlassian.confluence.themes.aqua.name" name="Aqua Theme" class="com.atlassian.confluence.themes.BasicTheme">
<description key="com.atlassian.confluence.themes.aqua.desc"/>
...
<resource type="stylesheet" name="my.css" location="styles/my-css.vm"/>
...
</theme>
...
Differences from Confluence 2.5.x
- You no longer have to include your theme stylesheet in the main decorator using
#pluginStylesheet
anymore. Confluence will load your theme's stylesheet automatically provided that its the active theme - The resource is declared in the
theme
module instead of thelayout
module - You need to start your custom style sheet (say
my-css.vm
), by copying over the latest styles fromhttp://yourhost/contextPath/styles/main-action.css
. This step is necessary as Confluence now includes either your theme stylesheet or the default stylesheet, not both. This implies:- you can no longer rely on the default styles being there to style parts of the Confluence you are not directly theming
- you are no longer overridding styles with your plugin style sheet. It is now the primary stylesheet
- you will need to merge any new styles in later versions of Confluence into your theme's style sheet
Multiple style sheets
It is possible to configure your theme to use multiple style sheets. This feature may useful if you want to break up your main style sheet into a few smaller style sheets with more defined purposes. You can declare these like so:
...
<theme key="aqua" i18n-name-key="com.atlassian.confluence.themes.aqua.name" name="Aqua Theme" class="com.atlassian.confluence.themes.BasicTheme">
<description key="com.atlassian.confluence.themes.aqua.desc"/>
...
<resource type="stylesheet" name="my1.css" location="styles/my-css1.vm"/>
<resource type="stylesheet" name="my2.css" location="styles/my-css2.vm"/>
<resource type="stylesheet" name="my3.css" location="styles/my-css3.vm"/>
...
</theme>
...
These style sheets will be included in the order in which they are declared.