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

[docs] Differentiate between packages in slotProps docs #9668

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions docs/data/data-grid/components/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ For example, for `columnMenu` slot, the interface name would be `ColumnMenuProps

This [file](https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/models/gridSlotsComponentsProps.ts) lists all the interfaces for each slot which could be used for augmentation.

```tsx
// augment the props for `toolbar` slot
<codeblock storageKey="pricing-plan">

```tsx Community
// augment the props for the toolbar slot
declare module '@mui/x-data-grid' {
interface ToolbarPropsOverrides {
someCustomString: string;
Expand All @@ -195,19 +197,69 @@ declare module '@mui/x-data-grid' {

<DataGrid
slots={{
// custom component passed to the `toolbar` slot
richbustos marked this conversation as resolved.
Show resolved Hide resolved
// custom component passed to the toolbar slot
toolbar: CustomGridToolbar,
}}
slotProps={{
toolbar: {
// props required by CustomGridToolbar
someCustomString: 'Hello',
someCustomNumber: 42,
},
}}
>
```

```tsx Pro
// augment the props for the toolbar slot
declare module '@mui/x-data-grid-pro' {
interface ToolbarPropsOverrides {
someCustomString: string;
someCustomNumber: number;
}
}

<DataGridPro
slots={{
// custom component passed to the toolbar slot
toolbar: CustomGridToolbar,
}}
slotProps={{
toolbar: {
// props required by `CustomGridToolbar`
// props required by CustomGridToolbar
someCustomString: 'Hello',
someCustomNumber: 42,
},
}}
>
```

```tsx Premium
// augment the props for the toolbar slot
declare module '@mui/x-data-grid-premium' {
interface ToolbarPropsOverrides {
someCustomString: string;
someCustomNumber: number;
}
}

<DataGridPremium
slots={{
// custom component passed to the toolbar slot
toolbar: CustomGridToolbar,
}}
slotProps={{
toolbar: {
// props required by CustomGridToolbar
someCustomString: 'Hello',
someCustomNumber: 42,
},
}}
>
```

</codeblock>

This demo below shows how to use the `slotProps` prop and module augmentation to pass a new prop `status` to the `footer` slot.

{{"demo": "CustomFooter.js", "bg": "inline"}}
Expand Down