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] Change background color of the Header Filters #16291

Closed
gatorsong opened this issue Jan 21, 2025 · 4 comments
Closed

[data grid] Change background color of the Header Filters #16291

gatorsong opened this issue Jan 21, 2025 · 4 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: css Design CSS customizability support: commercial Support request from paid users support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@gatorsong
Copy link

gatorsong commented Jan 21, 2025

The problem in depth

I'm using the header filters and trying to adjust the background color to white/transparent. The current style has both the column header and header filters both blue. I want to be able to distinguish from the top and bottom column headers.

Your environment

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

Search keywords: header filters background

Order ID: 106374

@gatorsong gatorsong added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Jan 21, 2025
@github-actions github-actions bot added the support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/ label Jan 21, 2025
@gatorsong
Copy link
Author

gatorsong commented Jan 21, 2025

What I'm working with...

Image

'& .datagrid-custom-header': {
  backgroundColor: theme.palette.primary.main,
  color: 'white',
},
'& .MuiDataGrid-sortIcon': {
  color: 'white',
},
'& .MuiDataGrid-menuIconButton': {
  color: 'white',
},
'& .MuiDataGrid-filterIcon': {
  color: 'white',
},
'& .MuiDataGrid-columnHeaderTitleContainer': {
  color: 'white',
  '.MuiSvgIcon-root': {
    color: 'white',
  },
},
'& .MuiDataGrid-columnHeader': {
  // Forced to use important since overriding inline styles
  height: 'unset !important',
  backgroundColor: theme.palette.primary.main,
  color: 'white',
  border: '1px solid white',
},
'& .MuiDataGrid-columnHeaderTitle': {
  whiteSpace: 'normal',
  lineHeight: 'normal',
},
'& .MuiDataGrid-columnHeaders': {
  // Forced to use important since overriding inline styles
  maxHeight: '168px !important',
},

@michelengelen
Copy link
Member

Hey @gatorsong ... there are a few things you can improve in your example:

  1. we have a prop for columnHeaderHeight and headerFilterHeight:

     columnHeaderHeight={30}
     headerFilterHeight={60}
  2. You should ideally use the gridClasses object to target the components. this is better to prevent bugs in future upgrades (when classNames change). As an example:

    - '& .MuiDataGrid-columnHeader': {
    + [`& .${gridClasses.columnHeader}`]: {
  3. You can target each header filter cell with this:

     [`& .${gridClasses.headerFilterRow} > .${gridClasses.columnHeader}`]: {
       background: theme.palette.secondary.main,
     },

Does that fix your use case?

@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information customization: css Design CSS customizability and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 22, 2025
@michelengelen michelengelen changed the title [question] Change background color of the Header Filters [data grid] Change background color of the Header Filters Jan 22, 2025
@gatorsong
Copy link
Author

Thanks

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Jan 22, 2025
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

@gatorsong 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.

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! customization: css Design CSS customizability support: commercial Support request from paid users support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants