Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion packages/x-data-grid/src/material/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ function formatFont(font: React.CSSProperties | undefined) {
if (!font) {
return undefined;
}
return `${font.fontWeight} ${font.fontSize} / ${font.lineHeight} ${font.fontFamily}`;
const fontSize = typeof font.fontSize === 'number' ? `${font.fontSize}px` : font.fontSize;
return `${font.fontWeight} ${fontSize} / ${font.lineHeight} ${font.fontFamily}`;
}

/**
Expand Down
30 changes: 30 additions & 0 deletions test/regressions/data-grid/DataGridFontSize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { DataGrid } from '@mui/x-data-grid';
import { createTheme, ThemeProvider } from '@mui/material/styles';

const columns = [{ field: 'id' }, { field: 'firstName' }, { field: 'lastName' }];

const rows = [
{ id: 1, lastName: 'Snow', firstName: 'Jon' },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei' },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime' },
];

export default function DataGridDemo() {
const theme = createTheme({
typography: {
body2: {
fontSize: 14,
},
},
});

return (
<ThemeProvider theme={theme}>
<Box sx={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} />
</Box>
</ThemeProvider>
);
}
Loading