Installation
Install the @gp-grid/react package, import the required stylesheet, and prepare your React project to render the high-performance gp-grid component today.
When upgrading, update all installed @gp-grid/* packages together and follow the migration guide.
Package Manager
Install @gp-grid/react using your preferred package manager:
npm install @gp-grid/reactRequirements
- React 18 or higher
- TypeScript 5.0+ (recommended)
Peer Dependencies
The package has the following peer dependencies that should be installed automatically:
react>= 18.0.0react-dom>= 18.0.0
TypeScript
gp-grid is written in TypeScript and includes built-in type definitions. No additional @types packages are required.
import { Grid, type ColumnDefinition, type GridProps } from "@gp-grid/react";Styles
Import the stylesheet once in your application (e.g. in main.tsx, App.tsx, or your global CSS):
import "@gp-grid/react/dist/styles.css";Or with standard CSS import:
@import "@gp-grid/react/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.
import { Grid, gridStyles } from "@gp-grid/react";
import { css } from "@emotion/css";
const gridClass = css(gridStyles, {
"& .gp-grid-container": { "--gp-grid-bg": "#181b1f" },
});
export const MyGrid = () => (
<div className={gridClass} style={{ height: 400 }}>
<Grid columns={columns} rowData={rows} rowHeight={36} />
</div>
);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).
Next Steps
Once installed, check out the Basic Usage guide to create your first grid.