Get started
The packages are on npm, so one install command is all you need. You can also start with a single script tag and no install.
Start with one script tag
You need no bundler and no install. Save the HTML below as an .html file and open it in a browser. The CSS is inside the script, so you do not load it separately.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Employees</title>
</head>
<body>
<div id="grid" style="height: 300px"></div>
<script src="https://cdn.maxmine.com/maxgrid/1.8.0/maxgrid.min.js"></script>
<script>
const api = MaxGrid.createGrid(document.getElementById('grid'), {
columns: [
{ id: 'name', title: 'Name' },
{ id: 'department', title: 'Department' },
{ id: 'salary', title: 'Salary', kind: 'number' },
],
rows: [
{ id: 1, name: 'Liam Carter', department: 'Engineering', salary: 84000 },
{ id: 2, name: 'Emma Wilson', department: 'Design', salary: 78000 },
],
rowKey: 'id',
});
</script>
</body>
</html>The CDN URL is a file this site serves itself, and it is the same build as the npm package. Plain JavaScript covers version pinning, integrity checks and CSP. If you use React, Vue or Angular, continue with the install step below.
Install
Install the framework package together with the theme package. For plain JavaScript, one package (maxgrid) includes the theme CSS.
pnpm add maxgridImport the theme CSS once, in your app entry point. Without it the grid renders unstyled.
import 'maxgrid/maxgrid.css';With a <script> tag, the CSS is already inside the script, so you load nothing else. With a bundler it is also added on the first createGrid call, and you only use the import above if you want to load it yourself. See Plain JavaScript for details.
Show an employee list
This example logs the rowKey when you click a row.
<div id="grid" style="height: 300px"></div>
<script src="https://cdn.maxmine.com/maxgrid/1.8.0/maxgrid.min.js"></script>
<script>
const api = MaxGrid.createGrid(document.getElementById('grid'), {
columns: [
{ id: 'id', title: '사번', width: 80 },
{ id: 'name', title: '이름' },
{ id: 'department', title: '부서' },
],
rows: [
{ id: 1, name: '김민준', department: '개발' },
{ id: 2, name: '이서연', department: '디자인' },
],
rowKey: 'id',
});
api.on('rowClicked', ({ rowKey }) => console.log(rowKey));
</script>With a bundler, import it with import { createGrid } from 'maxgrid'.
The docs site's renderer draws the same options like this. Click a row to see rowClicked fire; the Events page covers the payload.
Draw cells with components
To put a badge or a button in a cell instead of text, give the column's cellRenderer a framework component. For a cell's editing UI, use cellEditor.
import { reactCell } from '@maxgrid/react';
const columns = [{ id: 'active', title: 'Status', cellRenderer: reactCell(StatusBadge) }];How to write StatusBadge, how to pass context, and how state leaks while scrolling are in Cells from components.
If the grid is not visible
The grid fills the height of its own element: the container passed to createGrid in plain JavaScript, or the Grid / mx-grid element in React, Vue and Angular. With no height nothing shows, and a height on an outer element alone lets the grid grow and render every row. Give that element the height directly, as the examples do with height: 300. If the parent is a flex or grid item, you may also need min-height: 0.
To use dark mode, add data-mxg-theme="dark" to the grid or an ancestor. See Theme.
Supported browsers
| Browser | Versions |
|---|---|
| Chrome, Edge | 111 or later |
| Firefox | 121 or later |
| Safari (macOS, iOS) | 16.4 or later |
Use a current version and you are fine. These minimums come from when each feature the grid uses (:has(), color-mix(), @container, inert, ES2022) first shipped in each browser. We took the dates from the browsers' published support data and did not run old browsers ourselves, so treat the version numbers as intended minimums. Chrome/Edge 111 and Firefox 121 come straight from the features. For Safari the features alone would allow 16.2 (color-mix()), but we could not test Safari, so we set 16.4, the first version with full ES2022 support, as a deliberate safety margin.
- In older browsers the rules that use
:has()orcolor-mix()are skipped, so only the look changes (filter clear button, editor error mark, sorted header, focus ring). Showing and editing values still work. - Without
inert,@containeror modern JavaScript (ES2022), the sheet, modal scope, the narrow pager layout and script loading may not work. - Internet Explorer is not supported.
- Chrome, Edge, Firefox and Safari (macOS and iOS) are all supported; the minimum versions are in the table above. If you run into a problem, please post it on the support board with your browser name and version.
After the list works
- What differs per React, Vue and Angular: Framework guide
- Let users pick rows: Row selection and keyboard
- Let users change cells: Cell editing
- Send their changes to the server in one request: Save changes in a batch
- What changed in each version: Release notes