-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
scope: chartsChanges related to the charts.Changes related to the charts.type: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.typescriptwaiting for 👍Waiting for upvotes. Open for community feedback and needs more interest to be worked on.Waiting for upvotes. Open for community feedback and needs more interest to be worked on.
Description
All the slots in @mui/x-charts and @mui/x-charts-pro packages should support module augmentation.
This allows to pass custom props to your slots without casting the types.
Here is how it works on the data grid:
declare module '@mui/x-data-grid' {
interface ToolbarPropsOverrides {
name: string;
setName: (name: string) => void;
}
}You can then use your custom slot without any type casting:
function CustomToolbar({ name, setName }: PropsFromSlot<GridSlots['toolbar']>) {
return <input value={name} onChange={(event) => setName(event.target.value)} />;
}
function MyApp() {
const [name, setName] = React.useState('');
return (
<DataGrid
rows={[]}
columns={[]}
slots={{ toolbar: CustomToolbar }}
slotProps={{
toolbar: { name, setName },
}}
/>
);
}Search keywords:
flaviendelangle, alexfauquette, htollefsen, matmannion and hhhhhhhhhhhg
Metadata
Metadata
Assignees
Labels
scope: chartsChanges related to the charts.Changes related to the charts.type: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.typescriptwaiting for 👍Waiting for upvotes. Open for community feedback and needs more interest to be worked on.Waiting for upvotes. Open for community feedback and needs more interest to be worked on.