Skip to main content

Replace all styles at runtime

Replace the entire style object at runtime.

import canvasDatagrid from 'canvas-datagrid';
import data from '/data.json';

const app = document.getElementById('app');
const gridElement = document.createElement('div');
const grid = canvasDatagrid({
  parentNode: gridElement,
  data,
});

grid.style = {
  cellBackgroundColor: 'darkred',
  cellColor: 'goldenrod',
};

app.append(gridElement);