Skip to content

Run the examples on your computer ​

You can copy the code on an example page and use it as is. Where it runs depends on the framework. Pick your way in the table below.

You useWhere it runsTime
JavaScriptEdit and run it right away with Try it (the playground) on the example page. No setup.1 minute
One HTML fileSave the code as index.html and open it in a browser. No setup.1 minute
ReactCreate a project on your computer and run it there.About 10 min
VueCreate a project on your computer and run it there.About 10 min
AngularCreate a project on your computer and run it there.About 15 min

React, Vue and Angular need a build tool that turns the code into something a browser can read. That is why the playground does not run them. Set a project up once with the steps below, and after that you only copy an example into its files.

Open in an online editor ​

Each code tab of a gallery example page (JavaScript, React, Vue, Angular) has Open in StackBlitz and Open in CodeSandbox buttons. Pressing one opens a runnable project of that tab in a new browser tab.

  • The project has a package.json; MaxGrid packages are pinned to the exact released version, and @maxgrid/themes/grid.css is imported.
  • The first start takes about a minute to install packages; edits show up right away.
  • Nothing is sent before you press a button. When you do, the example code is sent to that service (the same note sits under the buttons).
  • Offline, the page shows how to run the example on your own computer instead.

What you need ​

Node.js ​

You need it to create React, Vue and Angular projects. Download the LTS (stable) version from the official site and install it.

  • Download: nodejs.org/en/download
  • When it finishes, open a new terminal (PowerShell on Windows, Terminal on Mac) and check.
bash
node -v
npm -v

If both print a version number, you are ready. Node.js 20 or later is recommended.

A code editor ​

An editor helps because you handle several files. This one is free and the most common.

JavaScript and one HTML file ​

  1. Open the HTML tab on the example page and press the copy button on the code block.
  2. Paste it into a text editor and save it as index.html.
  3. Double-click index.html and the grid appears in your browser.

You need an internet connection because the grid file is loaded from this site. To see a change, refresh the browser.

Good to know when saving the file ​

  • Windows Notepad: in the save dialog, set the file type to All files and name it index.html. Otherwise it is saved as index.html.txt and will not open.
  • Get it from the playground: the Save as HTML file button in the playground downloads your edited code as an .html file.
  • Internet connection: the grid file is loaded from this site, so you need to be online. An ad-blocking extension that blocks the address can leave the page blank.
  • If the page is blank: press F12 in the browser and look for red errors in the Console tab. The message tells you the cause.

If you want to experiment, Try it at the top right of the example page is the fastest way. Change the code in the playground and press Ctrl+Enter (⌘+Enter on Mac) to see it right away.

React ​

The React tab of an example has two files: ExampleGrid.tsx (connects the grid) and example.ts (the data and options).

1. Create the project ​

In a terminal, go to the folder where you want the project and run these in order. Press Enter to accept the default answers.

bash
npm create vite@latest my-grid -- --template react-ts
cd my-grid
npm install

2. Install MaxGrid ​

bash
npm install @maxgrid/react @maxgrid/themes

3. Add the files ​

  1. Save the example's example.ts as src/example.ts.
  2. Save the example's ExampleGrid.tsx as src/ExampleGrid.tsx.
  3. Open src/main.tsx, load the theme CSS and render ExampleGrid.
tsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import '@maxgrid/themes/grid.css';
import { ExampleGrid } from './ExampleGrid';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <ExampleGrid />
  </StrictMode>,
);

4. Run ​

bash
npm run dev

Open the address the terminal prints (usually http://localhost:5173) in a browser. If the grid appears, it worked. Press Ctrl+C in the terminal to stop.

Vue ​

The Vue tab has ExampleGrid.vue and example.ts.

1. Create the project ​

bash
npm create vite@latest my-grid -- --template vue-ts
cd my-grid
npm install

2. Install MaxGrid ​

bash
npm install @maxgrid/vue @maxgrid/themes

3. Add the files ​

  1. Save the example's example.ts as src/example.ts.
  2. Save the example's ExampleGrid.vue as src/ExampleGrid.vue.
  3. Add one line for the theme CSS to src/main.ts, and use ExampleGrid in src/App.vue.
ts
// src/main.ts
import { createApp } from 'vue';
import '@maxgrid/themes/grid.css';
import App from './App.vue';

createApp(App).mount('#app');
vue
<!-- src/App.vue -->
<script setup lang="ts">
import ExampleGrid from './ExampleGrid.vue';
</script>

<template>
  <ExampleGrid />
</template>

4. Run ​

bash
npm run dev

Open the address the terminal prints (usually http://localhost:5173) in a browser.

Angular ​

The Angular tab has example-grid.component.ts and example.ts.

1. Create the project ​

If you use npx, you do not have to install the Angular CLI separately. When it asks, choose CSS for the stylesheet format and No for server-side rendering (SSR).

bash
npx @angular/cli new my-grid
cd my-grid

2. Install MaxGrid ​

bash
npm install @maxgrid/angular @maxgrid/themes

3. Add the files ​

  1. Save the example's example.ts as src/app/example.ts.
  2. Save the example's example-grid.component.ts as src/app/example-grid.component.ts.
  3. Load the theme CSS at the top of src/styles.css.
  4. Change src/app/app.component.ts (or app.ts) as below.
css
/* src/styles.css */
@import '@maxgrid/themes/grid.css';
ts
// src/app/app.component.ts
import { Component } from '@angular/core';
import { ExampleGridComponent } from './example-grid.component';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [ExampleGridComponent],
  template: '<app-example-grid />',
})
export class AppComponent {}

4. Run ​

bash
npm start

Open the address the terminal prints (usually http://localhost:4200) in a browser.

If something does not work ​

  • The grid does not show. The grid fills the height of its parent. The example code sets a height, so check that no line is missing. Getting started has the details.
  • You get a Cannot find module error. Check that you saved each file under the right name in src and ran the install command.
  • An option from the example has no effect. The installed package may be older than the example. Update it to the latest (for React, npm install @maxgrid/react@latest; Vue and Angular work the same way).
  • There is no styling at all. Check that the line loading the theme CSS is there.

For more, continue with the Framework guide.