Skip to content

Grid Appearance

Grids take their colors from the theme's CSS variables (tokens), and a few switches turn parts of their look on or off. You can change them for every grid, or for a single grid, from your site CSS. You don't need to change the theme.

Switches

Each switch is a CSS variable set to 1 (on) or 0 (off):

Variable What it shows Class to turn it off
--s-stripes a background on every other row (--s-alt-row-bg) slick-no-odd-even
--s-cell-borders the lines between rows (--s-cell-border) slick-no-cell-border
--s-header-chrome the header's background, top border, shadow, column separators and always visible menu buttons slick-no-header-chrome

Set a switch on :root for all grids, or on a grid for that grid only. A value set closer to the grid wins:

/* stripes in every grid */
:root {
    --s-stripes: 1;
}

/* but not in the orders grid */
.s-OrderGrid {
    --s-stripes: 0;
}

Every grid has a s-{ClassName} class, like s-OrderGrid for OrderGrid, and a s-{Module}-{ClassName} class, like s-Northwind-OrderGrid, for when two grids share a name.

A switch you don't set comes from the theme. The Carbon theme and the themes based on it have no stripes. Azure, Cosmos, Glassy and Serene have them. All themes show cell borders and header chrome. Themes set their choice with --s-stripes-default, --s-cell-borders-default and --s-header-chrome-default, so a value you set for the switch itself always wins over the theme.

Hidden lines and backgrounds are transparent, not removed, so rows and headers keep their sizes when you turn them off.

--s-header-chrome only changes StartSharp grids. Serene's grid headers don't have this chrome to begin with.

Plain Tables

The slick-plain-table class turns all three off, so the grid looks like a plain table. It keeps the header's bottom line, the sort indicators, the row hover, and the menu button, which shows when the mouse is over a column header. To set it for a grid class, use the GridStyle flags below.

You can also set the switches in CSS, which lets you keep one of them, like the lines between the rows:

.s-ProductGrid {
    --s-stripes: 0;
    --s-cell-borders: 1;
    --s-header-chrome: 0;
}

Grid Style

GridStyle is a flags enum of what a grid hides of the look its theme gives to grids. A grid has no style by default, so it looks as the theme says:

Member Value Hides
NoStripes 1 the stripes (a change only for themes that have them)
NoCellBorders 2 the lines between the rows
NoHeaderChrome 4 the header's background, top border, shadow, column separators and always visible menu buttons
Lines 5 NoStripes and NoHeaderChrome: a plain header with lines between the rows
Plain 7 all three

Lines and Plain are only shortcuts for combinations of the others. A style can only hide what a theme shows, never show what it doesn't, so a grid in a theme without stripes looks the same with or without NoStripes. Use --s-stripes: 1 for that.

A grid class returns its style from getInitialGridStyle(), which DataGrid calls while the grid is created:

import { EntityGrid, GridStyle } from "@serenity-is/corelib";

export class ProductGrid extends EntityGrid<ProductRow> {
    protected override getInitialGridStyle() {
        return GridStyle.Lines;
    }
}

getInitialGridStyle() can use the grid's options, and setGridStyle(style) changes the style of a grid that is already created. Both add or remove the slick-no-odd-even, slick-no-cell-border and slick-no-header-chrome classes, so a grid's style is the same as its classes: you can also add them to the element yourself.

The table widget of StartSharp dashboards has a Table Style option with the same members, as a multi-select. Choose Lines or Plain, or combine the No ... members, and leave it empty to look like the other grids of the theme.

The slick-hide-header class hides the header row altogether. The check tree editor uses it together with slick-no-odd-even and slick-no-cell-border.

Colors

These tokens set the colors of grids. Themes set most of them, and you can override them on :root, on :root.theme-{id} for a theme, or on a grid:

Variable Used for
--s-alt-row-bg the background of every other row, when stripes are on
--s-cell-border the lines between rows, when cell borders are on
--s-row-hover-bg a tint over the row under the mouse (StartSharp themes; no hover tint when not set)
--s-row-active-bg the row of the active cell
--s-cell-active-bg the active cell
--s-column-header header text
--s-column-header-bg header background
--s-column-header-border header lines
--s-column-header-hover-bg the header column under the mouse
--s-group-row-bg group header rows, when grouping
--s-group-totals-bg, --s-group-totals-border, --s-group-totals-text group totals rows

Some of them are optional and have no value by default. The comments in tokens.css of Serenity.Extensions list every token with its default.

Grouped Rows

When a grid is grouped, group header rows have their own background (--s-group-row-bg) and no stripe. The rows of each group are striped from the group header, so the first row of every group has the same style as the first row of the grid, through the optional getRowStripe(row) method of SleekGrid's IDataView, which RemoteView and StartSharp's VirtualScrollView implement. Group totals rows take their colors from --s-group-totals-bg, --s-group-totals-border and --s-group-totals-text, so they are readable in dark themes.

The data rows of a grouped grid are indented under their group rows (indentDataRows of the group item metadata provider, on by default), through the slick-group-level-N classes and the --sg-group-indent variable instead of inline styles, so it works under a content security policy. The indentation stops at 8 levels.

Row and Cell States

Grid row and cell states each have one visual channel, so they add up instead of competing:

State Visual Token
Stripe the fill of every other row --s-alt-row-bg
Hover a layer over any fill --s-row-hover-bg (optional; StartSharp)
Current row a neutral tint --s-row-active-bg
Checked row a fill and a band at its start edge --s-row-checked-bg, --s-row-checked-accent
Row cursor a fill, for a grid that navigates rows --s-row-cursor-bg
Selected row/cell the primary color --s-cell-selected-bg
Being edited a fill --s-row-editing-bg
Active cell a ring (a box shadow), not a fill --s-cell-active-ring
Flashed cell a short highlight --s-cell-flash-bg

The fill of a cell belongs to one state by priority (stripe < current row < checked < row cursor < selected < being edited) and replaces the stripe, so a checked row does not also get the stripe, while the hover is a layer over any fill. A checked row is the one checked with its checkbox, not the one in a selection range of a selection model, so a multi selection reads apart from a hover, the cursor and a selection. A grid row is not tinted just because one of its cells is the active one; a grid that wants the row of the cursor highlighted, e.g. one that is edited a row at a time, sets the highlightActiveRow option.

The footer row of a grid, e.g. one with totals, is a band of its own: it is a bit shorter than a data row (26px, used to be 30px), takes the background of the column headers (--s-footer-row-bg overrides it), and mirrors the header: it keeps the line above it like the line below a header (both from --s-footer-row-border, --bs-border-color by default), follows the header chrome, so a plain grid has neither a background nor a line below it, and its totals use a stronger text color (--s-column-footer) and tabular numbers, so they line up under the columns.

Auto column width measures the footer row too, so a total is no longer cut off. The ignoreFooters option (a boolean, or a number that caps the width it adds) leaves it out.

Pinned Columns

The vertical scrollbar of a grid with columns pinned to the end is at the far end of the grid, after them, instead of between them and the scrolling columns: the pane of the pinned columns has it, the main pane reaches under it (endPaneScrollbar turns that off), and the container gets the sg-vbar-end class while it applies. The rows fill the width of the main pane when the columns are narrower than it, with an empty slick-cell sg-fill cell after the last column (fillRows), so their lines, stripes and fills reach the pinned columns or the end of the grid.

The panes of the pinned columns cast a shadow over the columns scrolled under them, instead of the dotted line that separated them, with no line at rest. --s-pinned-shadow sets the color of the shadow (transparent turns it off), and --s-pinned-border-style (e.g. solid, or dotted for the earlier look) draws a line in the color of --s-pinned-border. The container gets the sg-scrolled-start and sg-scrolled-end classes while the main pane is scrolled from its start, or has more to scroll towards its end.

Pager

The buttons that go to the first and last pages are left out by default, as the page box takes a number anyway. Set showFirstLast (or SlickPager.defaults.showFirstLast) to bring them back; while they are left out, shift+click on the previous and next buttons goes to the first and last pages instead.

The icon buttons of a pager are compact bordered squares that keep their place when disabled, with the border, background and corner radius coming from --s-pager-btn-border, --s-pager-btn-bg and --s-pager-btn-radius. They tell what they do to a tooltip and a screen reader, take the focus, and tell whether they are disabled through aria-disabled. The page box has no "Page" label before it anymore (the number and the page count tell what it is), and the gap above a pager is a fixed 7px instead of the row gap, so it does not leave a large space below the footer row of a grid.