-
-
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] New Toolbar component #14611
base: master
Are you sure you want to change the base?
Conversation
Deploy preview: https://deploy-preview-14611--material-ui-x.netlify.app/ Updated pages: |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
function CustomToolbar() { | ||
return ( | ||
<Toolbar.Root> | ||
<FilterPanel.Trigger render={<Toolbar.Button />}>Filters</FilterPanel.Trigger> |
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.
Interesting 🧐
In mui/base-ui#1349 the API is the opposite:
<Toolbar.Button render={<Select.Trigger />} />
(I stumbled onto this PR while searching for my own Toolbar doc in Notion 😅)
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.
Does the inverse work, also?
Either is valid in our case, but the outcome is different due to our parts rendering different Material UI components:

<Toolbar.Root>
<ColumnsPanel.Trigger render={<Toolbar.Button />}>
<ViewColumnIcon fontSize="small" />
</ColumnsPanel.Trigger>
<Toolbar.Button
render={
<ColumnsPanel.Trigger startIcon={<ViewColumnIcon fontSize="small" />}>
Columns
</ColumnsPanel.Trigger>
}
/>
</Toolbar.Root>
Toolbar.Button
renders an IconButton
, and ColumnsPanel.Trigger
renders a Button
.
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 turned out to be complicated, in my case Toolbar.Button
has to come first so the focusableWhenDisabled
prop/ability it provides can override the default "not focusable when disabled" of the inner Trigger/button-like thing it's rendering
I think toolbar is the first component where we really render a Base UI component as another Base UI component a lot, before we just focused on <BaseUIComponent render={<MyDesignSystemComponent />} />
Now toolbar opens up possibilities like this 😅
<Tooltip.Trigger
render={
<Toolbar.Button
render={
<Select.Trigger
render={
<Toggle render={<MyDesignSystemToggle />} />
}
/>
}
/>
}
/>
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.
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.
Added a follow-up action for this, I would like to add a toolbar-specific override.
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.
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.
Good spot—I've fixed the button styles, and the light toolbars will be fixed by mui/material-ui#45406
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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 mostly repetitive and minor style stuff—the bulk of the content is in great shape.
@@ -50,6 +50,13 @@ As mentioned above, the column menu is a component slot that can be recomposed e | |||
|
|||
### Toolbar | |||
|
|||
:::warning | |||
|
|||
The examples below use the `<GridToolbar />`, `<GridToolbarContainer />`, and various toolbar button components. |
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.
solid example of the component case in action - this text could be harder to understand if it was plain text 👍
"disabled": { "description": "If <code>true</code>, the component is disabled." }, | ||
"disableElevation": { "description": "If <code>true</code>, no elevation is used." }, | ||
"disableFocusRipple": { | ||
"description": "If <code>true</code>, the keyboard focus ripple is disabled." |
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.
"description": "If <code>true</code>, the keyboard focus ripple is disabled." | |
"description": "If <code>true</code>, the keyboard focus ripple is disabled." |
"description": "The component used to render a link when the <code>href</code> prop is provided." | ||
}, | ||
"onFocusVisible": { | ||
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too." |
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.
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too." | |
"description": "Callback fired when the component is focused with a keyboard. Also triggers an <code>onFocus</code> callback." |
}, | ||
"startIcon": { "description": "Element placed before the children." }, | ||
"sx": { | ||
"description": "The system prop that allows defining system overrides as well as additional CSS styles." |
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.
"description": "The system prop that allows defining system overrides as well as additional CSS styles." | |
"description": "The system prop for defining system overrides and additional CSS styles." |
docs/translations/api-docs/data-grid/toolbar-button/toolbar-button.json
Outdated
Show resolved
Hide resolved
"description": "The component used to render a link when the <code>href</code> prop is provided." | ||
}, | ||
"onFocusVisible": { | ||
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too." |
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.
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too." | |
"description": "Callback fired when the component is focused with a keyboard. Also triggers an <code>onFocus</code> callback." |
Adds a redesigned Toolbar component through a new composition API, documented here:
There are several related components that users can use to build a custom toolbar:
Note
This PR only adds the building blocks to create custom toolbars, and documentation for those components. I'm hoping we can release these in v7 for users to try out. There will be a follow up to update the default grid toolbar for v8 to use the new components. #15823
Closes #11584
Follow-up tasks: