Themes
Legacy Themes
The v19 release retired the old themes that are no longer shipped with ag-Grid.
If you are using an old theme, you should change it to it's new version. See table below:
| Old Theme | New Theme |
| ag-fresh | ag-theme-fresh |
| ag-dark | ag-theme-dark |
| ag-blue | ag-theme-blue |
| ag-material | ag-theme-material |
| ag-bootstrap | ag-theme-bootstrap |
ag-Grid is designed to have its look and feel derived from a theme. The following themes are available out of the box:
- ag-theme-balham
- The default flat light theme which is used in most of the examples in the documentation.
- ag-theme-balham-dark
- A dark variation of the balham theme, used in the enterprise examples in the documentation.
- ag-theme-material
- A theme designed according to the Google Material Language Specs.
- ag-theme-fresh
- A light gray theme.
- ag-theme-dark
- A dark grey theme.
- ag-theme-blue
- A light theme with blue headers.
- ag-theme-bootstrap
- Neutral / white theme that fits well in the context of bootstrap components. Notice: the theme does not have a bootstrap dependency.
To use a theme, add the theme class name to the div element where the ag-Grid directive is attached.
The following is an example of using the balham theme:
<div id="myGrid" class="ag-theme-balham"></div>
The following is an example of using the dark balham theme:
<div id="myGrid" class="ag-theme-balham-dark"></div>
When to Create a Theme
You have the following options when choosing a theme:
- Use one of the provided themes e.g.
ag-theme-balham.
- Use one of the provided themes and tweak using the provided Sass variables.
- Create your own theme from scratch. This is the most complex approach and you are more
exposed to breaking changes in ag-Grid releases.
You should only create your own theme when options 1 and 2 above don't suit, as it is
the most difficult.
If you do decide to create your own theme, then you can use one of the provided themes and
use that as a template. They can be found on GitHub here:
https://github.com/ceolter/ag-grid/tree/master/src/styles.
This section does not provide an example of building a theme as a number of themes
are already provided with ag-Grid - these can be used as a basis for any additional themes you may wish to create.
When to Style via Themes
Themes are intended to change the overall look and feel of a grid. If you want to style a particular
column, or a particular header, consider using either cell and header renderers, or applying CSS
classes or styles at the column definition level.
Sometimes it is possible to achieve the same effect using custom renderers as it is with themes.
If so, use whichever one makes more sense for you, there isn't a hard and fast rule.
What to Style via Themes
Any of the CSS classes described below can have style associated with them.
However you should be cautious about overriding style that is associated outside of the theme.
For example, the ag-pinned-cols-viewport, has the following style:
.ag-pinned-cols-viewport {
float: left;
position: absolute;
overflow: hidden;
}
The style attributes float, position and overflow are intrinsic to how the grid works. Changing
these values will change how the grid operates. If unsure, take a look at the styles associated
with an element using your browsers developer tools. If still unsure, try it out, if the style
you want to apply breaks the grid, then it's not a good style to apply!
Structure Example
The exact structure of the DOM within ag-Grid is dependent on its configuration and what
data is present. This page takes the below basic example grid, with one pinned column, as an
example to demonstrate the DOM structure. The reader is encouraged to inspect the DOM
(using your browsers developer tools) to dig deeper.
High Level Overview
The code below shows the hierarchy of the core div elements which form the four quadrants
of the table. The four quadrants are as follows:
- ag-pinned-header: Contains the pinned header cells. This container does not scroll.
- ag-header-container: Contains the non-pinned header cells. This container is within
a viewport (ag-header-viewport) that scrolls horizontally to match the position of the ag-body-viewport. This
container does not scroll vertically.
- ag-pinned-left-cols-container or ag-pinned-right-cols-container: Contains the pinned rows. This container is within a
viewport (ag-body-viewport) that scrolls vertically. This container does not scroll horizontally.
- ag-center-cols-container: Contains the non-pinned rows. This container is within a
viewport (ag-center-cols-viewport) that scrolls horizontally.
The ag-header-viewport does not have scrollbars. It only scrolls in response to changes to the ag-center-cols-viewport.
Detailed Breakdown
Below gives a detailed breakdown of the DOM for the example. In the example, the following is highlighted:
- Classes: These CSS classes can have style associated with them in a theme.
<div class="ag-root">
<!-- header -->
<div class="ag-header">
<div class="ag-pinned-left-header">
<div class="ag-header-row">
<!-- pinned header cell -->
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Athlete</span>
</div>
</div>
</div>
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Age</span>
</div>
</div>
</div>
</div>
</div>
<div class="ag-header-viewport">
<div class="ag-header-container">
<div class="ag-header-row">
<!-- main header cell -->
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Country</span>
</div>
</div>
</div>
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Year</span>
</div>
</div>
</div>
<!-- the other header cells... -->
</div>
</div>
</div>
</div>
<!-- body -->
<div class="ag-body-viewport>
<div class="ag-pinned-left-cols-container">
<div class="ag-row">
<div class="ag-cell">Michael Phelps</div>
<div class="ag-cell">23</div>
</div>
<div class="ag-row">
<div class="ag-cell">Michael Phelps</div>
<div class="ag-cell">19</div>
</div>
<!-- the other pinned rows... -->
</div>
<div class="ag-center-cols-viewport">
<div class="ag-center-cols-container">
<div class="ag-row">
<div class="ag-cell">United States</div>
<div class="ag-cell">2008</div>
<!-- the other row cells... -->
</div>
<div class="ag-row">
<div class="ag-cell">United States</div>
<div class="ag-cell">2004</div>
<!-- the other row cells... -->
</div>
<!-- the other body rows... -->
</div>
</div>
</div>
</div>
Styling with For Print
Styling with the option domLayout='print'
is similar to styling as normal, however the dom layout is much simpler.
When laying out for printing, there are no pinned columns and no viewports for scrolling.
<div class="ag-root ag-layout-print">
<!-- header -->
<div class="ag-header">
<div class="ag-header-viewport">
<div class="ag-header-container">
<div class="ag-header-row">
<!-- main header cell -->
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Athlete</span>
</div>
</div>
</div>
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Age</span>
</div>
</div>
</div>
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Country</span>
</div>
</div>
</div>
<div class="ag-header-cell">
<div class="ag-cell-label-container">
<div class="ag-header-cell-label">
<span class="ag-header-cell-text">Year</span>
</div>
</div>
</div>
<!-- the other header cells... -->
</div>
</div>
</div>
</div>
<!-- body -->
<div class="ag-body-viewport>
<div class="ag-center-cols-viewport">
<div class="ag-center-cols-container">
<div class="ag-row">
<div class="ag-cell">Michael Phelps</div>
<div class="ag-cell">23</div>
<div class="ag-cell">United States</div>
<div class="ag-cell">2008</div>
<!-- the other row cells... -->
</div>
<div class="ag-row">
<div class="ag-cell">Michael Phelps</div>
<div class="ag-cell">19</div>
<div class="ag-cell">United States</div>
<div class="ag-cell">2004</div>
<!-- the other row cells... -->
</div>
<!-- the other body rows... -->
</div>
</div>
</div>
</div>
Highlighting Rows and Columns
The class ag-row-hover and ag-column-hover are added
to cells as the mouse is dragged over the cells row or column.
The example below demonstrates the following:
-
CSS class
ag-row-hover has background color added to it,
so when you hover over a cell, the row will be highlighted.
-
CSS class
ag-column-hover has background color added to it,
so when you hover over a cell or a header, the column will be highlighted.
-
If you hover over a header group, all columns in the group will be highlighted.
Customizing the themes with Sass variables
ag-Grid themes are build using Sass.
This means that you can change the looks of the theme you use using Sass,
by overriding the theme variables value and referencing the Sass source files afterwards.
Some of the things you can change in the theme include:
- Changing the text / header / tool panel foreground and background colors
- Changing the icons size and color
- Changing the cell / row spacing*
* If you are going to change the row or header height, you should also modify the respective options in the JavaScript grid configuration.
This is a redundant step we are looking into removing in the future.
For a live example, see: Theme Customization Example Repository:
Following is a list of Sass variables, their default values, and a short explanation of their purpose.
| Variable Name |
Default Value |
Description |
| foreground-opacity |
1 |
The foreground opacity. |
| secondary-foreground-color-opacity |
1 |
The header font color opacity. |
| disabled-foreground-color-opacity |
0.5 |
The opacity of the disabled / empty text elements. |
| icon-color |
<no default> |
The icon color. |
| alt-icon-color |
<no default> |
The secondary icon, used on icons with two colors (eg. checkbox background). |
| foreground-color |
<no default> |
The default color of the text. |
| secondary-foreground-color |
<no default> |
The header font color. |
| disabled-foreground-color |
<no default> |
The color of the disabled / empty text elements. |
| menu-option-active-color |
<no default> |
The background color of the context / column menu items when hovered. |
| input-disabled-background-color |
#ebebeb |
The color of disabled input field |
| card-background-color |
<no default> |
The background color for the context menu and the column menu. |
| border-color |
<no default> |
The color used for all borders. |
| primary-color |
<no default> |
The main color associated with selected cells and other items (eg. cell border color, sidbar selected tab border). |
| accent-color |
<no default> |
The color for the checked checkboxes. |
| background-color |
<no default> |
The default background color. |
| odd-row-background-color |
<no default> |
The odd row background color. |
| editor-background-color |
<no default> |
The background color of cells being edited. |
| header-background-color |
<no default> |
The header background color. |
| header-cell-hover-background-color |
$header-background-color |
The header background color while hovering |
| header-cell-moving-background-color |
#bebebe |
The header background color while being moved. |
| header-foreground-color |
<no default> |
The header text color. |
| header-background-image |
<no default> |
The header background gradient - you can also refer to an an image with `url(...)`. |
| panel-background-color |
<no default> |
The background color of the column menu. |
| tool-panel-background-color |
<no default> |
The tool panel background color |
| chip-background-color |
<no default> |
The background color of the column labels used in the grouping / pivoting. |
| range-selection-background-color |
<no default> |
The background color of the selected cells. |
| hover-color |
<no default> |
The background color of the row when hovered. |
| selected-color |
<no default> |
The background color of selected rows. |
| cell-data-changed-color |
<no default> |
The background color used when the cell flashes when data is changed. |
| focused-cell-border-color |
<no default> |
The border color of the focused cell. |
| tab-background-color |
<no default> |
The background color of the tab in the column menu |
| cell-highlight-border |
<no default> |
The border used to mark cells as being copied. |
| cell-horizontal-border |
<no default> |
The border delimiter between cells. |
| ag-range-selected-color-1 |
<no default> |
The selection background color. |
| ag-range-selected-color-2 |
<no default> |
The selection background color when it overlaps with another selection (range) 1 level. |
| ag-range-selected-color-3 |
<no default> |
The selection background color when it overlaps with another selection (range) 2 levels. |
| ag-range-selected-color-4 |
<no default> |
The selection background color when it overlaps with another selection (range) 3 levels. |
| value-change-delta-up-color |
<no default> |
The color used when the cell value increases. |
| value-change-delta-down-color |
<no default> |
The color used when the cell value decreases. |
| value-change-value-highlight-background-color |
<no default> |
The background color used when the cell value changes. |
| row-floating-background-color |
<no default> |
The background color of the pinned rows. |
| row-stub-background-color |
<no default> |
The color of row stub background (see: Row Node) |
| grid-size |
4px |
The basic unit used for the grid spacing and dimensions. Changing this makes the grid UI more / less compact. |
| icon-size |
12px |
The icon width and height (icons are square). |
| header-height |
grid-size * 6 + 1 |
The header row height - if you change this, you also have to change the value of the `headerHeight` in the grid options. We are looking into removing this redundant step in the future. |
| row-height |
grid-size * 6 + 1 |
The row height - if you change this, you also have to change the value of the `rowHeight` in the grid options. We are looking into removing this redundant step in the future. |
| cell-horizontal-padding |
grid-size * 3 |
The cell horizontal padding. |
| virtual-item-height |
grid-size * 5 |
The height of virtual items (eg. Set Filter items). |
| header-icon-size |
14px |
The header icon height. |
| icons-path |
../../ag-theme-base/icons/ |
The path to the icon svg files. If you are to change that, make sure that the directory you point to contains the complete set of icons. |
| font-family |
'Helvetica Neue', sans-serif |
The grid font family. |
| font-size |
14px |
The grid font size. |
| font-weight |
400 |
The grid font weight |
| secondary-font-family |
font-family |
The font family used in the header. |
| secondary-font-size |
14px |
The header font size. |
| secondary-font-weight |
400 |
The header font weight. |
| card-shadow |
none |
Box shadow value for the context menu and the column menu. |
| card-radius |
0 |
Border radius for the context menu and the column menu. |
| row-border-width |
0 |
the row border width. |
| toolpanel-indent-size |
grid-size * icon-size |
The indent used for the tool panel hierarchy. |
| row-group-indent-size |
grid-size * 3 + icon-size |
The indent used for the row groups. |
| Variable Name |
Default Value |
| foreground-opacity |
0.87 |
| secondary-foreground-color-opacity |
0.54 |
| disabled-foreground-color-opacity |
0.38 |
| grid-size |
4px |
| icon-size |
16px |
| row-height |
grid-size * 7 |
| default-background |
#FFFFF; |
| chrome-background |
lighten(flat-clouds, 3) |
| active |
#0091EA |
| foreground-color |
#000000; |
| border-color |
flat-silver |
| icon-color |
flat-gray-4 |
| alt-background |
flat-clouds |
| odd-row-background-color |
#fcfdfe |
| header-cell-moving-background-color |
default-background |
| foreground-color |
rgba(foreground-color, foreground-opacity) |
| secondary-foreground-color |
rgba(foreground-color, secondary-foreground-color-opacity) |
| disabled-foreground-color |
rgba(foreground-color, disabled-foreground-color-opacity) |
| input-disabled-background-color |
#ebebeb |
| primary-color |
active |
| accent-color |
active |
| range-selection-background-color |
transparentize(active, 0.8) |
| ag-range-selected-color-1/td>
| opacify(range-selection-background-color, 0.1) |
| ag-range-selected-color-2 |
opacify(range-selection-background-color, 0.2) |
| ag-range-selected-color-3 |
opacify(range-selection-background-color, 0.3) |
| ag-range-selected-color-4 |
opacify(range-selection-background-color, 0.4) |
| range-selection-highlight-color |
active |
| selected-color |
lighten(active, 40) |
| alt-icon-color |
default-background |
| background-color |
default-background |
| editor-background-color |
chrome-background |
| panel-background-color |
chrome-background |
| tool-panel-background-color |
chrome-background |
| header-background-color |
chrome-background |
| header-foreground-color |
secondary-foreground-color |
| hover-color |
alt-background |
| chip-background-color |
darken(alt-background, 5) |
| row-stub-background-color |
inherit |
| row-floating-background-color |
inherit |
| cell-data-changed-color |
#fce4ec |
| value-change-delta-up-color |
#43a047 |
| value-change-delta-down-color |
#e53935 |
| value-change-value-highlight-background-color |
transparentize(#16A085, 0.5) |
| header-height |
grid-size * 8 |
| virtual-item-height |
grid-size * 7 |
| row-border-width |
1px |
| toolpanel-indent-size |
$grid-size + $icon-size |
| row-group-indent-size |
$grid-size * 3 + $icon-size |
| cell-horizontal-padding |
grid-size * 3 |
| header-icon-size |
14px |
| border-radius |
2px |
| icons-path |
"../../ag-theme-balham/icons/" |
| font-family |
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif |
| font-size |
12px |
| font-weight |
400 |
| secondary-font-family |
font-family |
| secondary-font-size |
12px |
| secondary-font-weight |
600 |
| Variable Name |
Default Value |
mat-grey-0 (color accessor) |
#ffffff |
mat-grey-50 (color accessor) |
#fafafa |
mat-grey-100 (color accessor) |
#f5f5f5 |
mat-grey-200 (color accessor) |
#eeeeee |
mat-grey-300 (color accessor) |
#e2e2e2 |
mat-indigo-500 (color accessor) |
#3f51b5 |
mat-pink-A200 (color accessor) |
#ff4081 |
mat-pink-50 (color accessor) |
#fce4ec |
mat-indigo-50 (color accessor) |
#e8eaf6 |
| foreground-opacity |
0.87 |
| secondary-foreground-color-opacity |
0.54 |
| disabled-foreground-color-opacity |
0.38 |
| grid-size |
8px |
| icon-size |
18px |
| header-height |
grid-size * 7 |
| row-height |
grid-size * 6 |
| row-border-width |
1px |
| toolpanel-indent-size |
grid-size + icon-size |
| row-group-indent-size |
grid-size * 3 + icon-size |
| cell-horizontal-padding |
grid-size * 3 |
| virtual-item-height |
grid-size * 5 |
| header-icon-size |
14px |
| icons-path |
"../icons/" |
| font-family |
"Roboto", sans-serif |
| font-size |
13px |
| font-weight |
400 |
| secondary-font-family |
"Roboto", sans-serif |
| secondary-font-size |
12px |
| secondary-font-weight |
700 |
| foreground-color |
rgba(#000, foreground-opacity) |
| secondary-foreground-color |
rgba(#000, secondary-foreground-color-opacity) |
| disabled-foreground-color |
rgba(#000, $disabled-foreground-color-opacity) |
| header-background-color |
$background-color |
| header-cell-hover-background-color |
darken($header-background-color, 5%) |
| header-cell-moving-background-color |
$header-cell-hover-background-color |
| header-foreground-color |
$secondary-foreground-color |
| border-color |
mat-indigo-300 |
| primary-color |
mat-indigo-500 |
| accent-color |
mat-pink-A200 |
| icon-color |
#333 |
| background-color |
mat-grey-0 |
| editor-background-color |
mat-grey-50 |
| panel-background-color |
mat-grey-200 |
| tool-panel-background-color |
mat-grey-50 |
| chip-background-color |
mat-grey-300 |
| range-selection-background-color |
mat-indigo-50 |
| range-selection-highlight-color |
mat-pink-50 |
| hover-color |
mat-grey-50 |
| selected-color |
mat-grey-200 |
| cell-data-changed-color |
mat-pink-50 |
| card-shadow |
0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12) |
| card-radius |
2px |
| value-change-delta-up-color |
#43a047 |
| value-change-delta-down-color: |
#e53935 |
| value-change-value-highlight-background-color |
#00acc1 |
You can examine the full, up-to-date list of the Sass variables and their usage in the source code of the themes.