1. Data Grid docs
  2. Columns and formatting

Themes

Follow the system's light or dark mode, pick a named skin or your own colour tokens, choose the row density and the interface language, per grid and at any time.

The grid takes its colours from its theme, set per grid with chrome. It can follow the system's light or dark mode, use one of the named skins it shares with Spreadsheet, or take your own colour tokens so it matches the app around it. The theme applies to the grid's element only and changes in place, without remounting.

Open the sales example and use its theme selector

Choices

chromeLook
'auto'Light or dark, following the system (the default)
'light', 'dark'Always light, always dark
'white', 'light-gray', 'dark-gray', 'colorful', 'black', 'slate'The named skins of the Spreadsheet editor
{ base, tokens }Your own: base is 'light' or 'dark', tokens overrides colours

Tokens you can set: panel (the grid's background), chrome (toolbar and headings), ink (text), ink-soft (secondary text), panel-line (lines), accent (buttons, focus, selection), on-accent (text on the accent colour) and hover. Any CSS colour works.

JavaScript

import { mountTable } from '@8sheets/data-grid';

const brand = { base: 'light', tokens: { accent: '#0f766e', 'on-accent': '#ffffff', panel: '#fbfbf9', 'panel-line': '#e4e4dd' } };
const grid = await mountTable(document.querySelector('#orders'), { title: 'Orders', data: orders, chrome: brand });

// Follow your app's own dark mode switch.
document.querySelector('#dark-mode').addEventListener('change', (e) => {
  grid.setChrome(e.target.checked ? { base: 'dark', tokens: { accent: '#2dd4bf', 'on-accent': '#04201d' } } : brand);
});

React

import { useMemo } from 'react';
import { DataGrid } from '@8sheets/data-grid-react';

export function Orders({ orders, dark }) {
  // Only `chrome` changed: the component calls setChrome, the grid stays mounted.
  const options = useMemo(() => ({
    title: 'Orders',
    data: orders,
    chrome: dark ? { base: 'dark', tokens: { accent: '#2dd4bf', 'on-accent': '#04201d' } } : { base: 'light', tokens: { accent: '#0f766e', 'on-accent': '#fff' } },
  }), [orders, dark]);
  return <div style={{ height: 480 }}><DataGrid options={options} /></div>;
}

Vue

<script setup>
import { computed } from 'vue';
import { DataGrid } from '@8sheets/data-grid-vue';

const props = defineProps({ orders: Array, dark: Boolean });
// Only `chrome` changed: the component calls setChrome, the grid stays mounted.
const options = computed(() => ({
  title: 'Orders',
  data: props.orders,
  chrome: props.dark ? 'dark' : { base: 'light', tokens: { accent: '#0f766e', 'on-accent': '#fff' } },
}));
</script>

<template>
  <div style="height: 480px"><DataGrid :options="options" /></div>
</template>

Angular

import { Component, Input } from '@angular/core';
import { DataGridComponent, DataGridOptions } from '@8sheets/data-grid-angular';

@Component({
  selector: 'app-orders',
  imports: [DataGridComponent],
  template: `<eight-data-grid [options]="options" style="height: 480px" />`,
})
export class Orders {
  private data: Record<string, unknown>[] = [];
  options: DataGridOptions = {};

  @Input() set orders(data: Record<string, unknown>[]) {
    this.data = data;
    this.options = { ...this.options, data };
  }
  // A new options object that differs only in `chrome` calls setChrome; the grid stays mounted.
  @Input() set dark(on: boolean) {
    this.options = { ...this.options, data: this.data, chrome: on ? 'dark' : { base: 'light', tokens: { accent: '#0f766e', 'on-accent': '#fff' } } };
  }
}

setChrome(chrome) changes the theme in place and getChrome() reads it. In the wrappers, a changed chrome option is passed to setChrome for you; the ref (or the Angular component) also has both methods.

Density

density sets the row height: 'compact' (28 px), 'normal' (34 px, the default) or 'comfortable' (40 px). The user picks it under Row height in the Columns dialog. setDensity('compact') changes it in place and getDensity() reads it.

const grid = await mountTable(el, { data: prices, density: 'compact' });
await grid.setDensity(window.innerWidth < 600 ? 'comfortable' : 'compact'); // larger rows for touch

Language

The interface comes in English ('en'), Polish ('pl'), German ('de'), French ('fr'), Spanish ('es') and Japanese ('ja'). Without language, the grid takes the browser's language when it has it, and English otherwise. setLanguage('de') switches it in place and getLanguage() reads it. A language other than English and Polish loads its texts the first time a grid uses it, so setLanguage returns a promise that resolves once the interface shows the new language.

const lang = document.documentElement.lang.slice(0, 2);
await grid.setLanguage(['en', 'pl', 'de', 'fr', 'es', 'ja'].includes(lang) ? lang : 'en');

The German, French, Spanish and Japanese texts are machine translations that haven't been reviewed yet.

setOptions({ … }) changes these and the other live options (title, scrolling, rowSelection, renderers, detailRenderer, detailMode, allowEdit, sharing, storageKey, density, columnGroups, contextMenu, rowNumbers, rowDrag, rowDrop, flashChanges, assistant, and every on… handler) without a new mount.

Limits

  • The theme sets colours and density sets the row height; the grid's layout and fonts are fixed.
  • The tokens style the grid's own element only, so two grids on one page can have different themes.
  • Conditional formatting presets (good, bad, warn, info) follow the light or dark base, not your tokens; give a rule its own color and background to match your brand.