Installation
Install the @gp-grid/angular package, import the required stylesheet, and prepare your Angular project to use 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/angular using your preferred package manager:
npm install @gp-grid/angularRequirements
- Angular 18 or higher (standalone components)
- TypeScript 5.0+ (recommended)
Peer Dependencies
@angular/core>= 18.0.0@angular/common>= 18.0.0
TypeScript
gp-grid is written in TypeScript and includes built-in type definitions:
import {
GpGridComponent,
type ColumnDefinition,
} from "@gp-grid/angular";Styles
Import the stylesheet once in your application. The recommended approach is in your global styles.css:
@import "@gp-grid/angular/dist/styles.css";Or in angular.json under the styles array:
"styles": [
"src/styles.css",
"node_modules/@gp-grid/angular/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 { Component } from "@angular/core";
import { GpGridComponent, gridStyles } from "@gp-grid/angular";
import { css } from "@emotion/css";
@Component({
selector: "app-my-grid",
standalone: true,
imports: [GpGridComponent],
template: `
<div [class]="gridClass" style="height: 400px">
<gp-grid [columns]="columns" [rowData]="rows" [rowHeight]="36" />
</div>
`,
})
export class MyGridComponent {
gridClass = css(gridStyles, {
"& .gp-grid-container": { "--gp-grid-bg": "#181b1f" },
});
}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
- See Basic Usage for your first grid