Theme API

Name Description
AddHtmlAttribute(string scope, string attributeName, string attributeValue) Adds new attribute for html element specified in function parameters.
KTTheme.AddHtmlAttribute("html", "direction", "rtl");
AddHtmlClass(string scope, string className) Adds new class for html element specified in function parameters.
KTTheme.AddHtmlClass("body", "header-fixed");
PrintHtmlAttributes(string scope) Returns all attributes by scope name, attributes are separated with space.
<html @Html.Raw(KTTheme.PrintHtmlAttributes("html"))>...</html>
PrintHtmlClasses(string scope) Returns classes by scope name, classes are separated with space.
<body class='@KTTheme.PrintHtmlClasses("body")'>...</body>
GetIcon(string iconName, string iconClass = "", string iconType = "") Returns a code of Keenicons icon wrapped with i tag, classes will be added on span element.
@Html.Raw(
    KTTheme.GetIcon("calendar", "fs-1 text-success", "duotone")
)
SetModeSwitch(bool flag) Enables/disables the mode switch.
KTTheme.SetModeSwitch(false);
IsModeSwitchEnabled() Checks if mode switch is enabled.
KTTheme.IsModeSwitchEnabled()
SetModeDefault(String mode) Sets the default theme mode. The supported values are light, dark and system.
KTTheme.SetModeDefault("dark")
GetModeDefault() Returns the default theme mode value.
KTTheme.GetModeDefault()
SetDirection(string direction) Sets theme direction LTR/RTL.
KTTheme.SetDirection("RTL");
GetDirection() Returns current theme direction.
KTTheme.GetDirection()
IsRtlDirection() Checks if currently RTL direction is enabled.
KTTheme.IsRtlDirection()
getAssetPath(string path) Returns full asset path path.
KTTheme.GetAssetPath("plugins/global/plugins.bundle.css");
GetView(string path) Returns layout view path in format ~/Views/Layout/{LayoutView}.
<partial name='@KTTheme.GetView("Partials/_Sidebar.cshtml")' />
GetPageView(string folder, string file) Returns page view path in format ~/Views/Pages/{PageType}/{PageView}.
KTTheme.GetPageView("Auth", "SignUp.cshtml")
ExtendCssFilename(string path) Extends css file name with .rtl to use RTL direction styles.
KTTheme.ExtendCssFilename("css/style.bundle.css")
GetFavicon() Returns favicon icon path from the configuration.
KTTheme.GetFavicon();
GetFonts() Returns array fonts from the configuration.
KTTheme.GetFonts();
GetGlobalAssets(String type) Returns theme global asset files defined in the configuration.
@foreach(string file in KTTheme.GetGlobalAssets("Css")){
    <link rel="stylesheet" type="text/css" href="@file" />
}
AddVendors(string[] vendors) Adds vendors for view.
KTTheme.AddVendors(new string[] {"datatables", "formrepeater"});
AddVendor(string vendor) Adds a vendor for view.
KTTheme.AddVendor("datatables");
AddJavascriptFile(string file) Adds a new javascript file for view.
KTTheme.AddJavascriptFile("/assets/js/custom/intro.js");
AddCssFile(string file) Adds a new css file for view.
KTTheme.AddCssFile("/assets/css/custom/intro.css");
GetJavascriptFiles() Returns a list of Javascript files.
@foreach(string file in KTTheme.GetJavascriptFiles()){
    <script src="@file"></script>
 }
GetCssFiles() Returns a list of CSS files.
@foreach(string file in KTTheme.GetCssFiles()){
    <link rel="stylesheet" type="text/css" href="@file" />
}
GetVendors(string type) Returns a list of Vendor files.
@foreach(string file in KTTheme.GetVendors("Js")){
    <script src="@file"></script>
}
GetAttributeValue(string scope, string attributeName) Returns attribute value, specified in params, scope, and attribute name.
KTTheme.GetAttributeValue("body", "data-kt-app-layout")
Preview Get Help Buy Now