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] How can I disable the data grid hover state? #10865

Open
RyleySill93 opened this issue Oct 31, 2023 · 3 comments
Open

[data grid] How can I disable the data grid hover state? #10865

RyleySill93 opened this issue Oct 31, 2023 · 3 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! support: commercial Support request from paid users support: question Community support but can be turned into an improvement

Comments

@RyleySill93
Copy link

RyleySill93 commented Oct 31, 2023

The problem in depth 🔍

How can I stop the hover styles from being applied to the DataGrid?
I'm using getRowClassName to set a custom background color for each of my rows so I can't just override the styling for the hover state to be a specific color.

Is there a way I can just disable any hover behavior entirely?

image

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: datagrid hover state
Order ID: 72462

@RyleySill93 RyleySill93 added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Oct 31, 2023
@DanailH
Copy link
Member

DanailH commented Nov 1, 2023

@RyleySill93 have you checked the examples here https://mui.com/x/react-data-grid/style/#using-the-sx-prop? You can use the sx prop to control the styling on various parts of the grid.

@DanailH DanailH added status: waiting for author Issue with insufficient information component: data grid This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 1, 2023
@DanailH DanailH changed the title [question] How can I disable the data grid hover state? [data grid] How can I disable the data grid hover state? Nov 1, 2023
@RyleySill93
Copy link
Author

RyleySill93 commented Nov 2, 2023

@DanailH Yup - the problem is I'm dynamically applying styles using the getRowClassName prop. So I can't just blanket override the Mui-hovered class with backgroundColor: #fff for example - I'm looking for Mui-hovered and MuiDataGrid-row:hover to have no effect.

The following almost works

    "&.MuiDataGrid-root .MuiDataGrid-row:hover": {
        backgroundColor: "inherit",
      },
      "&.MuiDataGrid-root .Mui-hovered": {
        backgroundColor: "inherit",
      },

But I get this behavior where the dynamically styled rows (getRowClassName is returning a class which styles the rows with a darker background color) are overridden:

Screen.Recording.2023-11-02.at.2.54.44.PM.mov

This is the state when being hovered:
image
The effect I'm looking for is the styling of background-color: #f7f6f4 which is being applied by the MuiDataGrid-odd class isn't overridden by the hover state.

@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 2, 2023
@DanailH
Copy link
Member

DanailH commented Nov 3, 2023

From the sound of it, this looks like a specific styling case you have, not a bug with the data grid itself. If it is the background you want to overwrite you can always set it to transparent, not inherit. Also, I don't see what the problem is with overwriting the hover styles since you are already adding custom classes to the row via getRowClassName.

@DanailH DanailH added support: question Community support but can be turned into an improvement and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! support: commercial Support request from paid users support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants