gridcn1.2.2

Styling

Value-driven styling on all four surfaces (grid-level and per-column class hooks, on shadcn tokens).

Styling never needs a fork: four class hooks cover every value-driven case, and everything resolves through existing shadcn tokens.

Patterns

Account
Region
Owner
Amount
Stage
Northwind Traders
AMER
Priya Nair
84000
Committed
Fabrikam Group
EMEA
Marcus Cole
41500
At risk
Contoso Retail
AMER
Dana Whitfield
120000
Committed
Tailspin Toys
APAC
Ilya Petrov
27800
Prospecting
Wide World Importers
EMEA
Grace Owusu
63200
At risk
Adatum Corp
APAC
Tom Bracewell
95400
Committed
Lucerne Publishing
AMER
Yuki Tanaka
18900
Prospecting
Proseware Inc
EMEA
Leah Fischer
52700
At risk
pnpm dlx shadcn@latest add @gridcn/data-grid-styling-patterns-demo
  • A brand column styled end to end with per-column cellClassName/headerClassName.
  • An at-risk row styled beyond a background tint via the grid-level getRowClassName.
  • A live density toggle: density="compact" | "default" | "comfortable", or an explicit rowHeight, which always wins.

Every surface, one dataset

Name
Dept.
Salary
Perf.
Status
Priya Nair
Engineering
128000
94
Active
Marcus Cole
Sales
76000
41
Active
Dana Whitfield
Support
58000
88
Active
Ilya Petrov
Engineering
141000
96
Active
Grace Owusu
Marketing
69000
47
On leave
Tom Bracewell
Sales
71000
33
Terminated
Yuki Tanaka
Engineering
118000
91
Active
Leah Fischer
Support
54000
62
Active
Omar Haddad
Marketing
73000
78
Active
Sophie Renard
Engineering
135000
45
On leave
pnpm dlx shadcn@latest add @gridcn/data-grid-conditional-styling-demo

The same HR dataset with all four value-driven surfaces active at once: grid-level getRowClassName/getCellClassName plus per-column cellClassName/headerClassName. The hooks receive the row value, so the class can depend on the data (at-risk, overdue, top score) instead of on a fixed state.

The contract

  • gridcn uses only existing shadcn tokens (bg-background, text-foreground, border-border, bg-muted, bg-primary, ring, bg-destructive) so theme switches carry over for free.
  • Static state (active cell, editing, pinned, read-only, cell type) is styled through the data-attribute contract: Styling & theming: data-attribute contract.
  • The two grid-specific CSS variables (--grid-row-height, --grid-pin-shadow) are on Styling & theming: CSS variables.

On this page