gp-grid-logo

Installation

Install the @gp-grid/vue package, import the required stylesheet, and prepare your Vue 3 project to use the high-performance gp-grid component everywhere.

When upgrading, update all installed @gp-grid/* packages together and follow the migration guide.

Package Manager

Install @gp-grid/vue using your preferred package manager:

npm install @gp-grid/vue

Requirements

  • Vue 3.5 or higher
  • TypeScript 5.0+ (recommended)

Peer Dependencies

The package has the following peer dependencies:

  • vue ^3.5.0

TypeScript

gp-grid is written in TypeScript and includes built-in type definitions:

<script setup lang="ts">
import { GpGrid, type ColumnDefinition, type GpGridProps } from "@gp-grid/vue";
</script>

Styles

Import the stylesheet once in your application (e.g. in main.ts or a global CSS file):

import "@gp-grid/vue/dist/styles.css";

Or with standard CSS import:

@import "@gp-grid/vue/dist/styles.css";

CSS-in-JS hosts and shadow roots

Some hosts don't allow importing a .css file. Grafana plugins, for example, must style through Emotion. For these cases the package also exports the same rules, minified, as the gridStyles string. Bundlers drop it when you don't use it.

<script setup lang="ts">
import { GpGrid, gridStyles } from "@gp-grid/vue";
import { css } from "@emotion/css";

const gridClass = css(gridStyles, {
  "& .gp-grid-container": { "--gp-grid-bg": "#181b1f" },
});
</script>

<template>
  <div :class="gridClass" style="height: 400px">
    <GpGrid :columns="columns" :row-data="rows" :row-height="36" />
  </div>
</template>
  • css() scopes every rule under its generated class, so put the class on an element around the grid.
  • The scope makes every rule one class more specific. Pass your overrides as later arguments to the same css() call; a separate global rule like .gp-grid-cell { ... } will lose. Setting the --gp-grid-* variables is the simplest way to theme.
  • With an older Emotion setup, injectGlobal(gridStyles) once behaves exactly like importing the file.
  • Inside a shadow root, put the string in a <style> element or a constructed stylesheet: sheet.replaceSync(gridStyles).

Vite Configuration

No special configuration needed. The package works out of the box with Vite.

Next Steps