SpreadsheetGrid

Loading the CSS and coexistence

Loading style.css / style.layer.css, and coexisting with Tailwind CSS, HeroUI, Mantine, StyleX, Astryx and UI SDK (the same for React and Solid)

The React and Solid versions use the same CSS files (style.css / style.layer.css / themes/*.css). Only the package name in the import path differs (@ishibashi0112/spreadsheet-grid/… for React, @ishibashi0112/spreadsheet-grid-solid/… for Solid).

Load the styles

Import it once, for example in your app's entry point.

import '@ishibashi0112/spreadsheet-grid/style.css'

The base styles are plain (unlayered) CSS scoped to .ssg-* classes, and the design tokens are defined with zero specificity (:where(.ssg-root)). So your overrides always win, whatever the import order. How to change colors and sizes with the tokens (--ssg-*) is in Theming and styling.

Coexisting with Tailwind CSS / HeroUI / Mantine / StyleX

  • Tailwind CSS v3 (+ HeroUI): works as is. Preflight's reset loses to class selectors on specificity, so it can't break the grid.

  • Tailwind CSS v4 (+ HeroUI): works as is. If you want Tailwind utilities to override the grid's defaults without the ! modifier, put the grid CSS in a layer below utilities:

    @import 'tailwindcss';
    @import '@ishibashi0112/spreadsheet-grid/style.css' layer(components);

    Or use the layered variant style.layer.css (everything in @layer ssg-base) and declare the layer order yourself:

    @layer theme, base, ssg-base, components, utilities;
    @import 'tailwindcss';
    @import '@ishibashi0112/spreadsheet-grid/style.layer.css';

    The declaration must be read before style.layer.css. @import it inside the CSS that declares the order, as above, or, when loading from JS, import it after the CSS with the declaration (if it loads first, ssg-base becomes the weakest layer).

    Use one of the two forms above too when you pass Tailwind utilities to classNames / cellClassName / getRowClassName to change the grid's default look (borders, rounded corners, text color and so on). With style.css loaded as is, Tailwind utilities, which live in a layer, lose to the grid's unlayered CSS whatever the load order, and have no effect (only ones with !, such as !rounded-none, work).

    // works with style.layer.css plus the layer order declaration
    <SpreadsheetGrid classNames={{ root: 'rounded-none border-x-0', bodyCell: 'text-red-600' }} /* … */ />
  • Mantine (React): works as is (no clashes in class names or resets; the grid's popovers use z-index: 1000, above Mantine's default modals).

  • StyleX: works as is (it has no reset, and its generated classes are prefixed with x, so they don't clash). You can pass the return value of stylex.props(...) ({ className, style }) straight to slots such as classNames / cellClassName / getRowClassName. StyleX's atomic classes have the same specificity as the grid's base classes, so load the grid CSS first and the StyleX output after it, or use style.layer.css (style.layer.css is required if you use useLayers in StyleX). Details are in Theming and styling.

  • Astryx (Meta's design system, built with StyleX): works as is (the grid's CSS isn't in a layer, so Astryx's @layer reset / @layer astryx-base can't break it).

  • UI SDK (a component library from Vercel Labs, in beta): works as is (UI SDK's CSS is inside @layer ui-sdk and uses :where / [data-slot] selectors, so it doesn't clash with the grid's unlayered CSS). Placed inside a UI SDK Dialog, the grid's popups appear inside the dialog. For letting an agent work on the table, and for keeping UI SDK's agent bridge from reading cell text (data-agent-hidden), see Let AI agents operate the table.

To match the colors to an Astryx / Mantine / HeroUI (v3) / shadcn/ui theme, load the matching theme (themes/astryx.css and others) after style.css. Details and demos are in Matching a design system.

To reliably override the grid's defaults with plain CSS, chain your own class onto the grid's base class so it wins on specificity:

.ssg-body-cell.my-warn-cell {
  background-color: #fff7ed;
}

On this page