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

[DataGrid] New Toolbar component #14611

Open
wants to merge 177 commits into
base: master
Choose a base branch
from

Conversation

KenanYusuf
Copy link
Member

@KenanYusuf KenanYusuf commented Sep 13, 2024

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:

@KenanYusuf KenanYusuf added component: data grid This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer proof of concept Studying and/or experimenting with a to be validated approach labels Sep 13, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 18, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 1, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 27, 2025
function CustomToolbar() {
return (
<Toolbar.Root>
<FilterPanel.Trigger render={<Toolbar.Button />}>Filters</FilterPanel.Trigger>
Copy link
Member

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 😅)

Copy link
Member Author

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:

Screenshot 2025-01-28 at 11 01 16
<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.

Copy link
Member

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 />} />
          }
        />
      }
    />
  }
/>

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 28, 2025
@KenanYusuf KenanYusuf added the customization: dom Component's DOM customizability, e.g. slot label Jan 28, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use the header background color for the toolbar as well?

image

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not look good on dark theme. Dark theme often receives less love :/

image

Copy link
Member Author

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

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Feb 24, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 24, 2025
Copy link
Contributor

@mapache-salvaje mapache-salvaje left a 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.
Copy link
Contributor

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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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."

"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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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."

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: dom Component's DOM customizability, e.g. slot design This is about UI or UX design, please involve a designer new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Improved Toolbar
7 participants