Skip to content
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

[data grid] DataGrid style when in dark mode and inside a dialog #15502

Closed
mauro-ni opened this issue Nov 20, 2024 · 6 comments
Closed

[data grid] DataGrid style when in dark mode and inside a dialog #15502

mauro-ni opened this issue Nov 20, 2024 · 6 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! customization: theme Centered around the theming features support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@mauro-ni
Copy link

mauro-ni commented Nov 20, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/p/sandbox/blue-fog-zknyzh
  2. Set theme to dark
  3. Open the dialog

Current behavior

As you can see, inside the dialog there is a DataGrid. The color of rows / cells borders is wrong.
In light mode everything is fine. Header background is too much dark.

Expected behavior

Borders should be visibile (ther should be more contrast with the background).
Also, background of header and pinned columns should match the dialog background.

Context

The context is DataGrid in dialogs.
I'm using css vars and set default & paper background to #303030

Your environment

I'm using Google Chrome.

npx @mui/envinfo
  System:
    OS: macOS 15.1.1
  Binaries:
    Node: 23.2.0 - /usr/local/bin/node
    npm: 10.9.0 - /usr/local/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 131.0.6778.71
    Edge: Not Found
    Safari: 18.1.1
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.3 
    @emotion/styled: ^11.13.0 => 11.13.0 
    @mui/base:  5.0.0-beta.61 
    @mui/core-downloads-tracker:  6.1.7 
    @mui/icons-material: ^6.1.7 => 6.1.7 
    @mui/lab: 6.0.0-beta.15 => 6.0.0-beta.15 
    @mui/material: ^6.1.7 => 6.1.7 
    @mui/private-theming:  6.1.7 
    @mui/styled-engine:  6.1.7 
    @mui/system: ^6.1.7 => 6.1.7 
    @mui/types:  7.2.19 
    @mui/utils:  6.1.3 
    @mui/x-data-grid:  7.22.2 
    @mui/x-data-grid-premium: ^7.22.2 => 7.22.2 
    @mui/x-data-grid-pro:  7.22.2 
    @mui/x-date-pickers:  7.22.2 
    @mui/x-date-pickers-pro: ^7.22.2 => 7.22.2 
    @mui/x-internals:  7.21.0 
    @mui/x-license: ^7.21.0 => 7.21.0 
    @types/react:  18.0.10 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript:  5.1.6 

Search keywords: datagrid dark dialog
Order ID: 97630

@mauro-ni mauro-ni added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 20, 2024
@github-actions github-actions bot added component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Nov 20, 2024
@michelengelen
Copy link
Member

We can do better with allowing for a better theming experience, I do agree.
For now we kind of only apply one thing, which is the pinned container background since those need to have a solid color to allow for elements below that (z-index lower) to not bleed through.
All other elements are basically transparent and only the text color changes.
You can customize the grid with styleOverrides though:

const theme = createTheme({
  cssVariables: {
    colorSchemeSelector: "class",
  },
  colorSchemes: { light: true, dark: true },
  palette: {
    mode: "dark", // Use dark mode
    background: {
      default: "#303030",
      paper: "#303030",
    },
  },
  components: {
    MuiDataGrid: {
      styleOverrides: {
        row: {
          backgroundColor: "#222",
        },
      },
    },
  },
});

I am not sure how far in we are with the design agnostic approach ... @romgrk know best about that and could elaborate on that a bit.

Would that mentioned workaround be useful for you for the moment @mauro-ni?

@michelengelen michelengelen added status: waiting for author Issue with insufficient information customization: theme Centered around the theming features and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 20, 2024
@michelengelen michelengelen changed the title DataGrid style when in dark mode and inside a dialog [data grid] DataGrid style when in dark mode and inside a dialog Nov 20, 2024
@mauro-ni
Copy link
Author

@michelengelen many thanks for you reply.

As you said, currently DataGrid set a background to pinned container and header.
The customization you provide doesn't take into account the footer and the space left in the body (when rows don't fill the DataGrid body).

In my projects I already added theme customization in order to get striped rows that also work with pinned columns (even if I don't like to repeat it on every project).

As far as I am concerned, from DX point of view, it would be better to have such features implemented by the library and activate them through DataGrid boolean props (eg. striped, inPaper). Probably the second property I suggest (inPaper) could be superfluous, if a different style for grids inside dialogs/papers can be provided.
What do you think?

Many thanks.

Mauro

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 20, 2024
@michelengelen
Copy link
Member

I am not sure how the team feels about adding more props that can be easily done with a line of CSS. There is a new issue opened by @KenanYusuf about adding background color to the grid in general to allow for easier theming of that: #15517

The striped rows with pinned columns is a bit weird, I get that. But this is on our radar already to be improved. There is an ongoing effort to allow for a design-agnostic grid that probably includes a lot of those small improvements as well.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 21, 2024
@mauro-ni
Copy link
Author

@michelengelen I agree.

The best solution is definitely to avoid new properties and have the grid background set automatically, depending on the context (dialog / page).

As for striped rows, I can't wait for these improvements to make it into a new release.

Many thanks.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 21, 2024
@michelengelen
Copy link
Member

I'll close this one in favor of #15517 👍🏼

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@mauro-ni How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! customization: theme Centered around the theming features support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants