Skip to content

Commit

Permalink
chore(ui): add custom styles to column menu items (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsherma authored Dec 5, 2024
1 parent 7c10a7e commit a259e4a
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* as we implement our own UI outside the grid for this. We still want the "Hide column" item,
* which is inconveniently tied to the "Manage columns" item in `columnMenuColumnsItem`.
*/
import {createTheme, ThemeProvider} from '@mui/material/styles';
import {
GridColumnMenu,
GridColumnMenuHideItem,
Expand All @@ -12,11 +13,27 @@ import React from 'react';

type Slots = Record<string, React.JSXElementConstructor<any> | null>;

// See: https://mui.com/x/react-data-grid/column-menu/#customize-column-menu-items
const columnMenuTheme = createTheme({
components: {
MuiTypography: {
styleOverrides: {
root: {
fontSize: '14px',
fontFamily: 'Source Sans Pro',
fontWeight: 400,
},
},
},
},
});
export const CallsCustomColumnMenu = (props: GridColumnMenuProps) => {
const slots: Slots = {columnMenuColumnsItem: null};
if (props.colDef.hideable ?? true) {
slots.columnMenuUserItem = GridColumnMenuHideItem;
}
return <GridColumnMenu {...props} slots={slots} />;
return (
<ThemeProvider theme={columnMenuTheme}>
<GridColumnMenu {...props} slots={slots} />
</ThemeProvider>
);
};

0 comments on commit a259e4a

Please sign in to comment.