Skip to main content

CSS color themes

View as Markdown
caution

This article describes a legacy method for adjusting the colors of UI elements such as toolbars and context menus. We recommend using the Custom themes API instead, as it provides greater flexibility and precision.

Connect the CSS file​

You can change the colors of UI elements with the CSS custom properties. To do this, you should specify these properties in a CSS file and connect the file to the library using the custom_css_url property in the Widget Constructor. See customization example in themed.html and themed.css filesΒ πŸ”Β (access is restricted).

Use the following CSS selectors to specify colors depending on the theme:

  • : root: not (.theme-dark) β€” for the light theme
  • .theme-dark: root β€” for the dark theme

Expand to view the code sample that sets up the pink widget for both light and dark theme.

:root:not(.theme-dark) {
--tv-color-platform-background: #d1c4e9;
--tv-color-pane-background: rgb(251, 223, 244);
--tv-color-toolbar-button-background-hover: rgb(244, 143, 177);
--tv-color-toolbar-button-background-expanded: rgb(244, 143, 177);
--tv-color-toolbar-button-background-active: rgb(249, 185, 233);
--tv-color-toolbar-button-background-active-hover: rgb(244, 143, 177);
--tv-color-toolbar-button-text: rgb(136, 24, 79);
--tv-color-toolbar-button-text-hover: rgb(74, 20, 140);
--tv-color-toolbar-button-text-active: red;
--tv-color-toolbar-button-text-active-hover: red;
--tv-color-item-active-text: rgb(6, 6, 255);
--tv-color-toolbar-toggle-button-background-active: red;
--tv-color-toolbar-toggle-button-background-active-hover: magenta;
--tv-color-toolbar-divider-background: rgb(251, 223, 244);
--tv-color-toolbar-save-layout-loader: rgb(106, 109, 120);

--tv-color-popup-background: rgb(241, 188, 225);
--tv-color-popup-element-text: rgb(136, 24, 79);
--tv-color-popup-element-text-hover: rgb(74, 20, 140);
--tv-color-popup-element-background-hover: rgb(244, 143, 177);
--tv-color-popup-element-divider-background: rgb(251, 223, 244);
--tv-color-popup-element-secondary-text: rgb(74, 20, 140);
--tv-color-popup-element-hint-text: rgb(74, 20, 140);
--tv-color-popup-element-text-active: rgb(6, 6, 255);
--tv-color-popup-element-background-active: red;
--tv-color-popup-element-toolbox-text: rgb(136, 24, 79);
--tv-color-popup-element-toolbox-text-hover: rgb(74, 20, 140);
--tv-color-popup-element-toolbox-text-active-hover: rgb(74, 20, 140);
--tv-color-popup-element-toolbox-background-hover: rgb(222, 89, 132);
--tv-color-popup-element-toolbox-background-active-hover: magenta;
}

.theme-dark:root {
--tv-color-platform-background: #d1c4e9;
--tv-color-pane-background: rgb(251, 223, 244);
--tv-color-toolbar-button-background-hover: rgb(244, 143, 177);
--tv-color-toolbar-button-background-expanded: rgb(244, 143, 177);
--tv-color-toolbar-button-background-active: rgb(249, 185, 233);
--tv-color-toolbar-button-background-active-hover: rgb(244, 143, 177);
--tv-color-toolbar-button-text: rgb(136, 24, 79);
--tv-color-toolbar-button-text-hover: rgb(74, 20, 140);
--tv-color-toolbar-button-text-active: red;
--tv-color-toolbar-button-text-active-hover: red;
--tv-color-item-active-text: rgb(6, 255, 6);
--tv-color-toolbar-toggle-button-background-active: red;
--tv-color-toolbar-toggle-button-background-active-hover: magenta;
--tv-color-toolbar-divider-background: rgb(251, 223, 244);
--tv-color-toolbar-save-layout-loader: rgb(134, 137, 147);

--tv-color-popup-background: rgb(241, 188, 225);
--tv-color-popup-element-text: rgb(136, 24, 79);
--tv-color-popup-element-text-hover: rgb(74, 20, 140);
--tv-color-popup-element-background-hover: rgb(244, 143, 177);
--tv-color-popup-element-divider-background: rgb(251, 223, 244);
--tv-color-popup-element-secondary-text: rgb(74, 20, 140);
--tv-color-popup-element-hint-text: rgb(74, 20, 140);
--tv-color-popup-element-text-active: rgb(6, 6, 255);
--tv-color-popup-element-background-active: red;
--tv-color-popup-element-toolbox-text: rgb(136, 24, 79);
--tv-color-popup-element-toolbox-text-hover: rgb(74, 20, 140);
--tv-color-popup-element-toolbox-text-active-hover: rgb(74, 20, 140);
--tv-color-popup-element-toolbox-background-hover: rgb(222, 89, 132);
--tv-color-popup-element-toolbox-background-active-hover: magenta;
}

Adjust properties on the fly​

To change or get the CSS custom properties values at runtime, use the setCSSCustomProperty or getCSSCustomPropertyValue methods, respectively.

widget.setCSSCustomProperty('--tv-color-pane-background', 'rgb(251, 223, 244)')

You can also use these methods to adjust your own variables defined in the CSS file.

List of CSS custom properties​

  • --tv-color-platform-background β€” the main color of the page where all elements are placed on
  • --tv-color-pane-background β€” toolbar background color
  • --tv-color-toolbar-button-background-hover β€” hover effect color for a toolbar button
  • --tv-color-toolbar-button-background-expanded β€” hover effect color for the active button on the right toolbar
  • --tv-color-toolbar-button-background-active β€” background color for the active button on the right toolbar
  • --tv-color-toolbar-button-background-active-hover β€” background color for the active button on the right toolbar when hovering over it
  • --tv-color-toolbar-button-text β€” text and icon color for toolbar buttons, including the arrows of dropdown buttons
  • --tv-color-toolbar-button-text-hover β€” text and icon color for toolbar buttons, including the arrows of dropdown buttons, when hovering over them
  • --tv-color-toolbar-button-text-active β€” text and icon color for toolbar buttons that are active
  • --tv-color-toolbar-button-text-active-hover β€” text and icon color for toolbar buttons that are active when hovering over them
  • --tv-color-item-active-text β€” text color for toggle toolbar buttons (e.g. magnet mode, lock all drawings)
  • --tv-color-toolbar-toggle-button-background-active β€” fill color for toggle toolbar buttons (e.g. magnet mode, lock all drawings)
  • --tv-color-toolbar-toggle-button-background-active-hover β€” fill color for toggle toolbar buttons when hovering over them (e.g. magnet mode, lock all drawings)
  • --tv-color-toolbar-divider-background β€” toolbar dividers color
  • --tv-color-toolbar-save-layout-loader β€” loader color for toolbar save layout button
  • --tv-color-toolbar-hider-icon β€” arrow icon color for the button that hides and shows a toolbar
  • --tv-color-bar-mark-background-color β€” background color for tooltips shown for bar marks

Pop-up menu properties​

Pop-up and pop-over menus appear when the user clicks on a toolbar icon. The pop-over menu typically presents a list of tools, options, or commands that are relevant to the context of the icon or the current user task. These styling options are also applied for context menus.

  • --tv-color-popup-background
  • --tv-color-popup-element-text
  • --tv-color-popup-element-text-hover
  • --tv-color-popup-element-background-hover
  • --tv-color-popup-element-divider-background
  • --tv-color-popup-element-secondary-text
  • --tv-color-popup-element-hint-text
  • --tv-color-popup-element-text-active
  • --tv-color-popup-element-background-active
  • --tv-color-popup-element-toolbox-text
  • --tv-color-popup-element-toolbox-text-hover
  • --tv-color-popup-element-toolbox-text-active-hover
  • --tv-color-popup-element-toolbox-background-hover
  • --tv-color-popup-element-toolbox-background-active-hover

Dialog and input properties​

  • --tv-color-symbol-search-background β€” background color for the items in the Symbol Search dialog, including its list of sources
  • --tv-color-symbol-search-highlighted-text β€” color for the text that matches the search query in the Symbol Search dialog
  • --tv-color-indicators-dialog-item-background-hover β€” background color for an item in the Indicators dialog when hovering over it
  • --tv-color-indicators-dialog-item-background-selected β€” background color for the selected item in the Indicators dialog
  • --tv-color-color-select-swatch-border β€” border color for the white swatch in the color inputs of the settings dialogs
  • --tv-color-input-border-hover β€” border color for input fields when hovering over them

Trading Platform properties​

The properties below are available in Trading Platform only.

Widget panel​

  • --tv-color-widgetbar-widget-border β€” border color between the widgets in the widget panel

Watchlist​

  • --tv-color-watchlist-header-text-hover β€” text color for a column header when hovering over it
  • --tv-color-watchlist-header-flag-icon β€” color for the flag icon in the column header
  • --tv-color-watchlist-header-flag-icon-hover β€” color for the flag icon in the column header when hovering over it
  • --tv-color-watchlist-marker-icon β€” color for the flag marker of a symbol that isn't flagged
  • --tv-color-watchlist-marker-icon-hover β€” color for the flag marker of a symbol that isn't flagged when hovering over it
  • --tv-color-watchlist-positive-text β€” text color for positive changes
  • --tv-color-watchlist-negative-text β€” text color for negative changes
  • --tv-color-watchlist-tick-up-text β€” text color for a price that has just gone up
  • --tv-color-watchlist-tick-down-text β€” text color for a price that has just gone down
  • --tv-color-watchlist-invalid-symbol-text β€” text color for the row of an invalid symbol
  • --tv-color-watchlist-warning-icon β€” color for the warning icon next to a symbol name
  • --tv-color-watchlist-separator-background-selected β€” background color for a selected section separator
  • --tv-color-watchlist-selected-row-button-background-hover β€” hover effect color for the buttons in a selected row
  • --tv-color-watchlist-tooltip-text β€” text color for the symbol tooltip
  • --tv-color-watchlist-tooltip-market-open-text β€” color for the market status in the symbol tooltip when the market is open
  • --tv-color-watchlist-tooltip-market-post-text β€” color for the market status in the symbol tooltip during post-market hours
  • --tv-color-watchlist-tooltip-market-closed-text β€” color for the market status in the symbol tooltip when the market is closed or on a holiday

Details​

  • --tv-color-details-secondary-text β€” color for secondary text, such as the additional description and the range titles
  • --tv-color-details-invalid-text β€” text color for the description of an invalid symbol
  • --tv-color-details-link-text-hover β€” color for links when hovering over them
  • --tv-color-details-bid-text β€” text color for the bid price
  • --tv-color-details-ask-text β€” text color for the ask price
  • --tv-color-details-range-bar-background β€” background color for the range bars
  • --tv-color-details-range-bar-fill-background β€” fill color for a range bar when the close is at or above the open
  • --tv-color-details-range-bar-fill-background-low β€” fill color for a range bar when the close is below the open