Show TOC

Loading External Custom ThemesLocate this document in the navigation structure

You want to use a theme that is not at the same location as the default libraries, you need to tell SAPUI5 where to find it.


You set this theme either by static declaring in the page or by using the Core.setThemeRoot() method. This is very much like using registerModulePath() for libraries that are at a different location.


  1. To define the path to the theme, add the following code: sap.ui.getCore().setThemeRoot("my_theme", "");

    This will cause SAPUI5 to load all theme resources from below this URL, for example the library.css file of the sap.ui.core library will be loaded from:

    • For easier usage this base directory can also be given as second argument to core.applyTheme(...) .

  2. If some parts of the theme are at are at different locations than others, you can use the above call to set the default, but override the theme location for specific libraries by specifying them in an array as second parameter: sap.ui.getCore().setThemeRoot("my_theme", ["","my.lib.two"], "");
  3. To statically configure the theme, you can use the global configuration object. Insert the following before the SAPUI5 bootstart script tag:
    <script type="text/javascript">
    window["sap-ui-config"] = {
    	themeRoots : {
    		"my_preconfigured_theme" : "",
    		"my_second_preconfigured_theme" : {
    			"" : "",
    			"sap.ui.core" : ""

    The first theme is completely at one location, while the second theme has the default location changed plus the location changed for the part of the theme that covers the sap.ui.core library.

    • Or it can be done (using the same object structure as JSON string) in an attribute of the SAPUI5 bootstrap script tag, for example:

      <script id="sap-ui-bootstrap" 
      	data-sap-ui-theme-roots='{"my_theme" : ""}'>
    • Last but not least, the location of a theme can be specified with a URL parameter: