docs

Control Development Guidelines: Theming/CSS

For themes and CSS for control development in OpenUI5, the following guidelines apply.


General Guidelines


Naming

The following naming guidelines apply:


Images

Themes (including “base”) should only refer to existing images inside that theme. Images will be loaded relative to the theme where they are referenced (see LESS option "relativeUrls")

If an image URL defined in base stays active in another theme 'mytheme', derived from base, LESS will calculate a relative URL that points from the mytheme/library.css to the base/library.css.

Similar path calculation is necessary when the URL is defined in another library (e.g. from sap/m/themes/mytheme/library.css tosap/ui/core/themes/base/image.png).

These URL transformations assume a single repository for all sources. When resources for different themes or libraries are located in different libraries, such relative URLs might not work.

To override an image within the base theme an additional rule has to be added to the individual theme referencing the image. Otherwise the base image will be loaded.


CSS Math Functions

CSS Math Functions must be escaped in LESS to prevent incorrect calculations and syntax errors.

Example for calc:

.sapUiMyControl {
    width: ~"calc(100% - 3rem)";
}

Example for min + calc:

.sapUiMyControl {
    height: ~"min(48rem, calc(80vh - 5rem))";
}

LESS Theme Parameters

For LESS theme parameters, the following guidelines apply: