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] Toolbar button slotProps get overwritten by slotProps.baseButton #13416

Open
KenanYusuf opened this issue Jun 7, 2024 · 0 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! customization: css Design CSS customizability

Comments

@KenanYusuf
Copy link
Contributor

KenanYusuf commented Jun 7, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/focused-pike-nzz36y?file=%2Fsrc%2FDemo.tsx

Steps:

  1. Set some button prop overrides on the data grid like: slotProps={{ baseButton: { variant: "contained", color: "primary" } }}
  2. Add a custom toolbar and render a button e.g. GridToolbarColumnsButton
  3. Add some button prop overrides on the toolbar button e.g. slotProps={{ button: { variant: "outlined", color: "secondary" } }}

Current behavior

The slotProps.baseButton props take precedence over the slotProps.button props on GridToolbarColumnsButton.

Expected behavior

When rendering individual buttons within the toolbar, I should be able to customize the button variant, color etc.

In the above example, the toolbar column button should be the outlined variant and secondary color.

I haven't dived into this too much, but I think we need to switch the order of {...buttonProps} and {...rootProps.slotProps?.baseButton} on these buttons:
https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/components/toolbar/GridToolbarColumnsButton.tsx#L72-L74

Context

Trying to style toolbar buttons differently to the other buttons in the UI.

Your environment

No response

Search keywords: data grid slotProps baseButton toolbar button props

@KenanYusuf KenanYusuf added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jun 7, 2024
@cherniavskii cherniavskii added the customization: css Design CSS customizability label Jun 11, 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: css Design CSS customizability
Projects
None yet
Development

No branches or pull requests

2 participants