-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Add default background color to grid #16066
Conversation
const pinnedBackground = t.mixins.MuiDataGrid?.pinnedBackground ?? containerBackground; | ||
: (t.mixins.MuiDataGrid?.background ?? t.palette.background.default); | ||
const headerBackground = t.mixins.MuiDataGrid?.headerBackground ?? background; | ||
const pinnedBackground = t.mixins.MuiDataGrid?.pinnedBackground ?? background; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, containerBackground
is applied to column headers and pinned rows. IMO, it makes more sense to use the pinnedBackground
color for pinned rows. With this change, containerBackground
would only change the color of column headers, hence why I have renamed it to headerBackground
.
It would be a second breaking change in addition to adding a background color to the grid.
Any concerns with this change? @mui/xgrid
@@ -663,7 +664,7 @@ export const GridRootStyles = styled('div', { | |||
backgroundColor: pinnedSelectedBackgroundColor, | |||
}, | |||
}, | |||
[`& .${c.virtualScrollerContent} .${c.row}`]: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/data/data-grid/style/style.md
Outdated
// Headers, and top & bottom fixed rows | ||
containerBackground: '#343434', | ||
// Container background | ||
background: '#fafaf9', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to handle dark mode here? It would be great to have this included in this demo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned here #16066 (comment) and updated the docs
const background = t.vars | ||
? t.vars.palette.background.default | ||
: (t.mixins.MuiDataGrid?.containerBackground ?? t.palette.background.default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't t.mixins.MuiDataGrid?.containerBackground
be used if provided, regardless of t.vars
?
const background =
t.mixins.MuiDataGrid?.containerBackground ??
(t.vars ? t.vars.palette.background.default : t.palette.background.default);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the priority was wrong, good spot. Fixed e2e9b02
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
// Pinned rows and columns background | ||
pinnedBg: '#f1f5f9', | ||
// Column header background | ||
headerBg: '#eaeff5', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another breaking change to make Data Grid theming consistent with Material UI.
Instead of using the mixins
theme property, we add DataGrid
to the palette
—in addition to being consistent with other component color options, this gives us built-in support for light/dark mode theming with colorSchemes
(as shown in the snippet below this).
Material use bg
instead of background
, so also updated the property names for consistency.
docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md
Outdated
Show resolved
Hide resolved
docs/data/data-grid/style/style.md
Outdated
@@ -116,26 +116,64 @@ The following demo illustrates how this can be achieved. | |||
|
|||
{{"demo": "StripedGrid.js", "bg": "inline"}} | |||
|
|||
## Theme header and pinned sections | |||
## Theme container, header and pinned sections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oxford comma. 😁 and is "Theme" necessary here? If not I think it's better without, for the sake of keeping the header as short as possible. I'm on the fence about whether or not to pluralize everything so I'll leave that to your judgement.
## Theme container, header and pinned sections | |
## Containers, headers, and pinned sections |
}, | ||
}, | ||
}); | ||
``` | ||
|
||
Material UI v6 users can use the `colorSchemes` property to specify different colors for light and dark mode: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be nice to add h3s for ### Material UI v6
and ### Material UI v5
so users can quickly differentiate between the two samples when skimming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! The sections are quite specific to light and dark mode theming so I've added that to the headings:
- Light and dark mode in Material UI v5
- Light and dark mode in Material UI v6
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
1 similar comment
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: Kenan Yusuf <[email protected]>
Signed-off-by: Kenan Yusuf <[email protected]>
Closes #15517
Changelog
Breaking changes
The Data Grid now has a default background color, and its customization has moved from
theme.mixins.MuiDataGrid
totheme.palette.DataGrid
with the following properties:bg
: Sets the background color of the entire grid (new property)headerBg
: Sets the background color of the header (previously namedcontainerBackground
)pinnedBg
: Sets the background color of pinned rows and columns (previously namedpinnedBackground
)