Context.officeTheme property
Provides access to the properties for Office theme colors.
Important: This API currently works only in Excel, PowerPoint, and Word in Office 2016 Preview on Windows desktop.
Hosts: | Excel, PowerPoint, Word |
Available in Requirement set | Not in a set |
Added in | 1.3 |
Office.context.officeTheme
Members
Properties
Name | Description |
bodyBackgroundColor | Gets the Office theme body background color. |
bodyForegroundColor | Gets the Office theme body foreground color. |
controlBackgroundColor | Gets the Office theme control background color. |
controlForegroundColor | Gets the Office theme control foreground color. |
Remarks
Using Office theme colors let's you coordinate the color scheme of your add-in with the current Office theme selected by the user with File > Office Account > Office Theme UI, which is applied across all Office host applications.
Example
function applyOfficeTheme(){
// Get office theme colors.
var bodyBackgroundColor = Office.context.officeTheme.bodyBackgroundColor;
var bodyForegroundColor = Office.context.officeTheme.bodyForegroundColor;
var controlBackgroundColor = Office.context.officeTheme.controlBackgroundColor
var controlForegroundColor = Office.context.officeTheme.controlForegroundColor;
// Apply body background color to a CSS class.
$('.body').css('background-color', bodyBackgroundColor);
}
Support details
Minimum permission level | Restricted |
Add-in types | Content, task pane |
Library | Office.js |
Namespace | Office |
Support history
Version | Changes |
---|---|
1.3 | Introduced |