Theme API

Name Description
addHtmlAttribute(String scope, String attributeName, String attributeValue) Adds new attribute for html element specified in function parameters.
theme.addHtmlAttribute("html", "direction", "rtl");
addHtmlClass(String scope, String className) Adds new class for html element specified in function parameters.
theme.addHtmlClass("body", "header-fixed");
printHtmlAttributes(String scope) Returns all attributes by scope name, attributes are separated with space.
<body th:attr="__${@theme.printHtmlAttributes('body')}__">...</body>
printHtmlClasses(String scope) Returns classes by scope name, classes are separated with space.
<body th:class="${@theme.printHtmlClasses('body')}">...</body>
getIcon(String path, String classNames) Returns a code of svg icon wrapped with span tag, classes will be added on span element.
[(${@theme.getIcon('duotune/general/gen022.svg', 'svg-icon fs-1')})]
setModeSwitch(bool flag) Enables/disables the mode switch.
theme.setModeSwitch(false);
isModeSwitchEnabled() Checks if mode switch is enabled.
theme.isModeSwitchEnabled()
setModeDefault(String mode) Sets the default theme mode. The supported values are light, dark and system.
theme.setModeDefault("dark")
getModeDefault() Returns the default theme mode value.
theme.getModeDefault()
setDirection(String direction) Sets theme direction LTR/RTL.
theme.setDirection("RTL");
getDirection() Returns current theme direction.
theme.getDirection()
isRtlDirection() Checks if currently RTL direction is enabled.
theme.isRtlDirection()
getAssetPath(String path) Returns full asset path path.
theme.getAssetPath("plugins/global/plugins.bundle.css");
getView(String path) Returns layout view path in format ~/Views/Layout/{LayoutView}.
theme.getView("partials/sidebar");
getPageView(String folder, String file) Returns page view path in format ~/Views/Pages/{PageType}/{PageView}.
theme.getPageView("auth", "sign-up")
extendCssFilename(String path) Extends css file name with .rtl to use RTL direction styles.
theme.extendCssFilename("css/style.bundle.css")
getFavicon() Returns favicon icon path from the configuration.
theme.getFavicon();
getFonts() Returns array fonts from the configuration.
theme.getFonts();
getGlobalAssets(String type) Returns theme global asset files defined in the configuration.
<link th:each="file: ${@theme.getGlobalAssets('Css')}" rel="stylesheet" type="text/css" th:href="@{${file}}" />
addVendors(String[] vendors) Adds vendors for view.
String[] vendors = {"amcharts", "amcharts-maps", "amcharts-stock"};
theme.addVendors(vendors);
addVendor(String vendor) Adds a vendor for view.
theme.addVendor("datatables");
addJavascriptFile(String file) Adds a new javascript file for view.
theme.addJavascriptFile("/assets/js/custom/intro.js");
addCssFile(String file) Adds a new css file for view.
theme.addCssFile("/assets/css/custom/intro.css");
getJavascriptFiles() Returns a list of Javascript files.
<script th:each="file: ${@theme.getJavascriptFiles()}" th:src="${@theme.getAssetPath(file)}"></script>
getCssFiles() Returns a list of CSS files.
<link th:each="file: ${@theme.getCssFiles()}" rel="stylesheet" type="text/css" th:href="@{${@theme.getAssetPath(file)}}" />
getVendors(String type) Returns a list of Vendor files.
<script th:each="file: ${@theme.getVendors('Js')}" th:src="${file}"></script>
getAttributeValue(String scope, String attributeName) Returns attribute value, specified in params, scope, and attribute name.
theme.getAttributeValue("body", "data-kt-app-layout")
Preview Get Help Buy Now