Theming & Styling
React KD-Grid is built with Tailwind CSS and CSS Variables, making it incredibly flexible to style and customize for your application's design system.
Dark Mode
The grid automatically detects the .dark class on your root HTML element and switches its internal color palette. There's no extra prop needed for basic dark mode support.
Auto-Light Detection
Auto-Dark Adaptation
CSS Variables
Override the default theme by redefining these CSS variables in your global stylesheet.
globals.css
@tailwind base;
@tailwind components;
@tailwind utilities;
/* Customizing the grid via CSS variables */
:root {
--kd-grid-bg: white;
--kd-grid-border: #e5e7eb;
--kd-grid-header-bg: #f9fafb;
--kd-grid-row-hover: #f3f4f6;
--kd-grid-accent: #3b82f6;
}
.dark {
--kd-grid-bg: #030712;
--kd-grid-border: #1f2937;
--kd-grid-header-bg: #111827;
--kd-grid-row-hover: #1f2937;
--kd-grid-accent: #60a5fa;
}Conditional Styling
Use rowClassName and className (on columns) to apply styles based on data values.
// Row conditional style
<DataGrid
rowClassName={(row) => row.status === 'error' ? 'bg-red-50 text-red-600' : ''}
/>
// Column conditional style
{
key: "score",
header: "Score",
className: (v) => v > 90 ? "text-green-600 font-bold" : "text-gray-500"
}