Documentation

Common Types

NameDescription
GridColumnA column description. Passed to the columns property.
GridCellThe basic interface for defining a cell
GridSelectionThe most basic representation of the selected cells in the data grid.
ThemeThe theme used by the data grid to get all color and font information

GridColumn

Grid columns are the basic horizontal building block of the data grid. At their most basic level a GridColumn is just an object which contains a title and a width or id. Their type looks like:

interface BaseGridColumn {
    readonly title: string;
    readonly group?: string;
    readonly icon?: GridColumnIcon | string;
    readonly overlayIcon?: GridColumnIcon | string;
    readonly hasMenu?: boolean;
    readonly style?: "normal" | "highlight";
    readonly grow?: number;
    readonly themeOverride?: Partial<Theme>;
    readonly trailingRowOptions?: {
        readonly hint?: string;
        readonly addIcon?: string;
        readonly targetColumn?: number | GridColumn;
        readonly themeOverride?: Partial<Theme>;
        readonly disabled?: boolean;
    };
}

interface SizedGridColumn extends BaseGridColumn {
    readonly width: number;
    readonly id?: string;
}

interface AutoGridColumn extends BaseGridColumn {
    readonly id: string;
}

export type GridColumn = SizedGridColumn | AutoGridColumn;
PropertyDescription
titleThe title of the column
groupThe name of the group the column belongs to
iconThe icon the column belongs to. The icon must be either one of the predefined icons or an icon passed to the headerIcons prop
overlayIconAn icon which is painted on top offset bottom right of the icon. Must be a predefined icon or an icon passed to the headerIcons prop
hasMenuEnables/disables the menu dropdown indicator. If not enabled, onHeaderMenuClick will not be emitted.
styleMakes the column use the highlighted theming from the Theme. themeOverride can be used to perform the same effect.
growWhen set to a number > 0 the column will grow to consume extra available space according to the weight of its grow property.
themeOverrideA Partial<Theme> which can be used to override the theming of the header as well as all cells within the column.
trailingRowOptionsOverrides the DataEditor level prop for trailingRowOptions for this column

GridCell

GridCell is the basic content building block of a data grid. There are many types of cells available out of the box and more available in additional packages.

Cell KindDescription
UriDisplays uris. Can be edited.
TextDisplays arbitrary text.
ImageDisplays one or more images.
RowIDDesigned to show primary keys in data sources.
NumberDisplays numbers with formatting options and better editing support.
BubbleDisplays lists of data in little bubbles.
BooleanDisplays a checkbox which can be directly edited if desired.
LoadingUseful for when data is loading. Rendering is basically free.
MarkdownDisplays markdown when opened.
DrilldownSimilar to a bubble cell, but allows embedding text and images with each cell.
ProtectedDisplays stars instead of data. Useful for indicating that hidden data is present but unavailable to the user.
CustomHas no rendering by default and must be provided via a custom renderer

All grid cells support the following properties

interface BaseGridCell {
    readonly allowOverlay: boolean;
    readonly lastUpdated?: number;
    readonly style?: "normal" | "faded";
    readonly themeOverride?: Partial<Theme>;
    readonly span?: readonly [number, number];
    readonly contentAlign?: "left" | "right" | "center";
    readonly cursor?: CSSProperties["cursor"];
}
PropertyDescription
allowOverlayDetermins if an overlay editor or previewer should be shown when activating this cell.
lastUpdatedIf set, the grid will render this cell with a highlighted background which fades out. Uses performance.now() instead of Date.now().
styleIf set to faded the cell will draw with a transparent appearance.
themeOverrideA partial theme override to use when drawing this cell.
spanIf set the span controls which horizontal span a cell belongs to. Spans are inclusive and must be correctly reported for all cells in the span range.
contentAlignChanges the default text alignment for the cell.
cursorAn override for the cell cursor when hovered.

GridSelection

GridSelection is the most basic representation of the selected cells, rows, and columns in the data grid. The current property accounts for the selected cell and the range of cells selected as well. It is the selection which is modified by keyboard and mouse interaction when clicking on the cells themselves.

The rows and columns properties both account for the columns or rows which have been explicitly selected by the user. Selecting a range which encompases the entire set of cells within a column/row does not implicitly set it into this part of the collection. This allows for distinguishing between cases when the user wishes to delete all contents of a row/column and delete the row/column itself.

interface GridSelection {
    readonly current?: {
        readonly cell: Item;
        readonly range: Readonly<Rectangle>;
        readonly rangeStack: readonly Readonly<Rectangle>[];
    };
    readonly columns: CompactSelection;
    readonly rows: CompactSelection;
}

The cell is the [col, row] formatted cell which will have the focus ring drawn around it. The range should always include the cell and represents additional cells which can be edited via copy, delete and other events. The range may or may not include partial spans depending on the spanRangeBehavior set.


Theme

The data grid uses the Theme provided to the DataEditer in the theme prop. This is used to style editors as well as the grid itself. The theme interface is flat. The data grid comes with a built in theme which it will use to fill in any missing values.

PropertyTypeCSS VariableDescription
accentColorstring--gdg-accent-colorThe primary accent color of the grid. This will show up in focus rings and selected rows/headers.
accentFgstring--gdg-accent-fgA foreground color which works well on top of the accent color.
accentLightstring--gdg-accent-lightA lighter version of the accent color used to hint selection.
textDarkstring--gdg-text-darkThe standard text color.
textMediumstring--gdg-text-mediumA lighter text color used for non-editable data in some cases.
textLightstring--gdg-text-lightAn even lighter text color
textBubblestring--gdg-text-bubbleThe text color used in bubbles
bgIconHeaderstring--gdg-bg-icon-headerThe background color for header icons
fgIconHeaderstring--gdg-fg-icon-headerThe foreground color for header icons
textHeaderstring--gdg-text-headerThe header text color
textGroupHeaderstring | undefined--gdg-text-group-headerThe group header text color, if none provided the textHeader is used instead.
textHeaderSelectedstring--gdg-text-header-selectedThe text color used for selected headers
bgCellstring--gdg-bg-cellThe primary background color of the data grid.
bgCellMediumstring--gdg-bg-cell-mediumUsed for disabled or otherwise off colored cells.
bgHeaderstring--gdg-bg-headerThe header background color
bgHeaderHasFocusstring--gdg-bg-header-hasThe header background color when its column contains the selected cell
bgHeaderHoveredstring--gdg-bg-header-hoveredThe header background color when it is hovered
bgBubblestring--gdg-bg-bubbleThe background color used in bubbles
bgBubbleSelectedstring--gdg-bg-bubble-selectedThe background color used in bubbles when the cell is selected
bgSearchResultstring--gdg-bg-search-resultThe background color used for cells which match the search string
borderColorstring--gdg-border-colorThe color of all vertical borders and horizontal borders if a horizontal override is not provided
horizontalBorderColorstring | undefined--gdg-horizontal-border-colorThe horizontal border color override
drilldownBorderstring--gdg-drilldown-borderThe ring color of a drilldown cell
linkColorstring--gdg-link-colorWhat color to render links
cellHorizontalPaddingnumber--gdg-cell-horizontal-paddingThe internal horizontal padding size of a cell.
cellVerticalPaddingnumber--gdg-cell-vertical-paddingThe internal vertical padding size of a cell.
headerFontStylestring--gdg-header-font-styleThe font style of the header. e.g. bold 15px
baseFontStylestring--gdg-base-font-styleThe font style used for cells by default, e.g. 13px
fontFamilystring--gdg-font-familyThe font family used by the data grid.
editorFontSizestring--gdg-editor-font-sizeThe font size used by overlay editors.
lineHeightnumberNoneA unitless scaler which defines the height of a line of text relative to the ink size.