Skip to content

Commit da85d57

Browse files
[docs] Explain how to use theme augmentation (#2582)
1 parent 93b1f32 commit da85d57

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

docs/pages/api-docs/data-grid/data-grid-pro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { DataGridPro } from '@mui/x-data-grid-pro';
1010

1111
## Component name
1212

13-
The name <code>MuiDataGridPro</code> can be used when providing [default props](/customization/globals/#default-props) or [style overrides](/customization/globals/#css) in the theme.
13+
The name <code>MuiDataGrid</code> can be used when providing [default props](/customization/theme-components/#default-props) or [style overrides](/customization/theme-components/#global-style-overrides) in the theme.
1414

1515
## Props
1616

docs/pages/api-docs/data-grid/data-grid.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { DataGrid } from '@mui/x-data-grid';
1010

1111
## Component name
1212

13-
The name <code>MuiDataGrid</code> can be used when providing [default props](/customization/globals/#default-props) or [style overrides](/customization/globals/#css) in the theme.
13+
The name <code>MuiDataGrid</code> can be used when providing [default props](/customization/theme-components/#default-props) or [style overrides](/customization/theme-components/#global-style-overrides) in the theme.
1414

1515
## Props
1616

docs/src/pages/components/data-grid/getting-started/getting-started.md

+24
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ export default function App() {
9797

9898
{{"demo": "pages/components/data-grid/getting-started/Codesandbox.js", "hideToolbar": true, "bg": true}}
9999

100+
## TypeScript
101+
102+
In order to benefit from the [CSS overrides](/customization/theme-components/#global-style-overrides) and [default prop customization](/customization/theme-components/#default-props) with the theme, TypeScript users need to import the following types.
103+
Internally, it uses module augmentation to extend the default theme structure.
104+
105+
```tsx
106+
// When using TypeScript 4.x and above
107+
import type {} from '@mui/x-data-grid/themeAugmentation';
108+
import type {} from '@mui/x-data-grid-pro/themeAugmentation';
109+
110+
const theme = createTheme({
111+
components: {
112+
// Use `DataGrid` on both DataGrid and DataGridPro
113+
MuiDataGrid: {
114+
styleOverrides: {
115+
root: {
116+
backgroundColor: 'red',
117+
},
118+
},
119+
},
120+
},
121+
});
122+
```
123+
100124
## Licenses
101125

102126
The data grid comes with two different licenses:

0 commit comments

Comments
 (0)