There are several things you should keep in mind to ensure that an application can actually be themed.
Do not hard-code colors and fonts if you want your control or application to be themable in the theme designer tool.
For example, if you hard-coded the font color to black, this color cannot be adjusted when you apply a custom theme. This can be problematic if you want to apply a custom theme with a dark background color because the font color cannot be adjusted to a light color.
Parameters.get\(\)
from module sap/ui/core/theming/Parameters
. These parameters not only differ in terms of themes, they are also not necessarily stable across different versions of OpenUI5. For this reason, you cannot rely on the completeness of the set of parameters.This set is available across all predefined themes and should be handled with care. You should test your implementations for all themes to ensure the results are as expected.
Note:
This approach can only cover the most common use cases. In addition, be aware that due to parameter value changes with future versions of OpenUI5 it might be necessary to rework your applications even when using the “stable” theme parameters described here.
Read appropriate parameter values via API and set the elements’ CSS properties rather than hard-coding colors or borrowing arbitrary style classes from control sets:
sap.ui.require(["sap/ui/core/theming/Parameters"], function(Parameters){
var myColor = Parameters.get("sapUiButtonHoverBorderColor");
});