Matching a design system
themes/*.css matches the grid's colors to the theme variables of Astryx / Mantine / HeroUI / shadcn/ui
The grid works as is inside each design system and Tailwind CSS (the grid's CSS isn't put in a layer, so other resets don't break it; see Loading the CSS and coexistence). To match colors too, load the theme for the design system you use, in one line. A theme is just CSS that connects the design system's color variables to the grid's tokens (--ssg-*). No JS is added.
| Design system | CSS to load | Where it applies |
|---|---|---|
| Astryx | themes/astryx.css | Every grid on pages with <Theme> |
| Mantine | themes/mantine.css | Every grid on pages with MantineProvider |
| HeroUI (v3) | themes/heroui.css | Every grid on pages that load it |
| shadcn/ui | themes/shadcn.css | Every grid on pages that load it |
Demo
The badges in the status column and the buttons in the actions column are each design system's components placed inside cells (shadcn/ui is used by copying components, so the same classes as Button / Badge are written). You can compare them with the components outside, in the row above. Check light and dark with the site's theme switch.
The Astryx screen opens on StackBlitz as a Vite project (with a light / dark / system switch).
Usage
Load every theme after style.css (loaded before, it has no effect). Some colors, such as tooltips, stay with the grid's theme preset, so pass light / dark to theme too.
ref in React 18. For the Solid version, see "Solid version" below.When you wrap it in your own component and pass a ref, as with function Grid(props) in the examples below, make the wrapper forwardRef in React 18 (in React 19, ref arrives as a prop, but in React 18 it doesn't, and since SpreadsheetGridProps has ref, the types pass anyway).
import { forwardRef } from 'react';
import type { SpreadsheetGridHandle, SpreadsheetGridProps } from '@ishibashi0112/spreadsheet-grid';
// a form where ref arrives in both React 18 and 19
const Grid = forwardRef<SpreadsheetGridHandle<Row>, SpreadsheetGridProps<Row>>(function Grid(props, ref) {
const scheme = useComputedColorScheme('light'); // the design system's light / dark (see the examples below)
return <SpreadsheetGrid {...props} ref={ref} theme={scheme} />;
});Solid version
The theme files exist in the Solid version too; load them from @ishibashi0112/spreadsheet-grid-solid/themes/ + the theme name + .css (the contents are the same as the React version, and so is loading after @ishibashi0112/spreadsheet-grid-solid/style.css). Themes only read the design system's color CSS variables, so the design system's React components aren't needed.
- On pages with shadcn/ui's color variables (in the Tailwind CSS v4 form) or that load HeroUI's color CSS (
@heroui/styles), it follows as is (light / dark withtheme="class"). - The Astryx and Mantine themes apply within the scope that has the
data-astryx-theme/data-mantine-color-schemeattribute (usually<html>). In React these attributes are set by<Theme>/MantineProvider, so in a Solid app set them yourself along with the color CSS, and pass light / dark totheme. - The wrapping component doesn't need
forwardRef(Solid'srefarrives in props).
Astryx
<Theme>). In Solid, set the attributes yourself as in "Solid version" above.import '@astryxdesign/core/reset.css';
import '@astryxdesign/core/astryx.css';
import '@astryxdesign/theme-neutral/theme.css';
import '@ishibashi0112/spreadsheet-grid/style.css';
import '@ishibashi0112/spreadsheet-grid/themes/astryx.css';
import { Theme, useTheme } from '@astryxdesign/core/theme';
import { neutralTheme } from '@astryxdesign/theme-neutral/built';
// inside <Theme>, pass the effective light / dark to the grid
function Grid(props: SpreadsheetGridProps<Row>) {
const { mode } = useTheme(); // 'light' | 'dark' (mode="system" is resolved too)
return <SpreadsheetGrid {...props} theme={mode} />;
}
<Theme theme={neutralTheme} mode="system">
<Grid rows={rows} columns={columns} onRowsChange={setRows} rowKeyGetter={(row) => row.id} />
</Theme>;With Astryx, passing mode to theme is required. Astryx colors are decided with light-dark(), and depending on the build, light or dark is chosen on the side of the grid's theme (the color-scheme it sets).
When using it with Tailwind CSS, declare the layer order before Tailwind as in Astryx's README (Next.js + Tailwind) (the grid's CSS is unlayered, so it applies regardless of this order).
@layer reset, theme, base, astryx-base, astryx-theme, components, utilities;
@import 'tailwindcss';Mantine
MantineProvider). In Solid, set the attributes yourself as in "Solid version" above.import '@mantine/core/styles.css';
import '@ishibashi0112/spreadsheet-grid/style.css';
import '@ishibashi0112/spreadsheet-grid/themes/mantine.css';
import { MantineProvider, useComputedColorScheme } from '@mantine/core';
// inside MantineProvider, pass the effective light / dark to the grid
function Grid(props: SpreadsheetGridProps<Row>) {
const scheme = useComputedColorScheme('light');
return <SpreadsheetGrid {...props} theme={scheme} />;
}
<MantineProvider defaultColorScheme="auto">
<Grid rows={rows} columns={columns} onRowsChange={setRows} rowKeyGetter={(row) => row.id} />
</MantineProvider>;It follows the theme's primaryColor (accent) and defaultRadius (corner radius) too.
HeroUI (v3)
/* globals.css (as in HeroUI's setup) */
@import 'tailwindcss';
@import '@heroui/styles';import '@ishibashi0112/spreadsheet-grid/style.css';
import '@ishibashi0112/spreadsheet-grid/themes/heroui.css';
// HeroUI's light / dark is decided by the dark class on <html> (next-themes and so on).
// theme="class" looks at that class in CSS, so colors are right from the server render (no hook needed).
<SpreadsheetGrid {...props} theme="class" />It uses HeroUI v3's color variables (--surface / --accent and others). HeroUI v2 (which puts HSL components in --heroui-*) isn't covered. HeroUI v3's components (@heroui/react) need React 19. In React 18 apps, you can use only the color CSS (@heroui/styles) and this theme (placing components in cells needs React 19).
shadcn/ui
import '@ishibashi0112/spreadsheet-grid/style.css';
import '@ishibashi0112/spreadsheet-grid/themes/shadcn.css';
// light / dark with theme="class", as with HeroUI (follows the dark class on <html>)It uses the color variables shadcn/ui's init writes in globals.css (--background / --primary / --border and others). The form for Tailwind CSS v4 (values are colors themselves, like oklch(...)) is covered; the form for Tailwind CSS v3 (values are HSL components like 222.2 84% 4.9%) doesn't produce colors. There are no variables for success / warning colors, so the saved mark and the note mark use Tailwind's green-600 / amber-500.
What matches
- Backgrounds and text of cells and headers, borders, the accent (active cell / selection / checkboxes), popovers and menus, the colors of error / saved / note marks, and corner radius. They follow when you change the design system's theme (including custom themes) or switch light / dark.
- How grid colors are derived from the design system's variables (the strength of row hover, how the selection is mixed and so on) is the same for every theme.
- Parts without matching variables in the design system, such as tooltips, the ghost while dragging and conditional formatting colors, stay with the preset (light / dark) passed to
theme. - To change only some colors, write the tokens you want to change, like
.ssg-root { --ssg-cell-bg: ... }, and they win over the theme regardless of load order (theme selectors are:wherewith specificity 0). Colors like the selection are derived from the design system's accent, so to change the accent as a whole, change it on the design system's side (Mantine'sprimaryColorand so on). - When
style.cssis in a layer (loadingstyle.csswithlayer(components)/ usingstyle.layer.css), put the theme in the same layer afterstyle.csstoo. Token overrides put in a layer (Tailwind's[--ssg-accent:...]and so on) lose to an unlayered theme.
@import 'tailwindcss';
@import '@ishibashi0112/spreadsheet-grid/style.css' layer(components);
@import '@ishibashi0112/spreadsheet-grid/themes/shadcn.css' layer(components);Other design systems, or Tailwind CSS alone
With Tailwind CSS alone there are no color variables, so write the grid's tokens (--ssg-*) directly. You can paste the CSS made in the theme builder as is. For the list of tokens, see Theming and styling.
Notes
- Versions checked:
@astryxdesign/core0.7 (beta) /@mantine/core9.7 (8.3 was also checked to have the variables the theme uses) /@heroui/react3.2 /shadcn4.22. When variable names change, the themes follow. - HeroUI and shadcn/ui variables have no marker attribute, so those themes apply to every grid on the pages that load them. Loading them on pages without those variables leaves colors missing.
- When StyleX output is in a layer (
useLayers) and you want its classes to override the grid's base, usestyle.layer.css(Using it with StyleX).