在材料表上将TablePaging设置为from时出现问题



我正试图通过为材料表上的from-to of x行编号设置样式

import MaterialTable from 'material-table'
import { TablePagination, withStyles } from '@material-ui/core'
const StyledPagination = withStyles({
caption: {
'&.MuiTypography-caption': {
fontSize: '1.5rem !important'
},
fontSize: '1.5rem !important'
}
})(TablePagination)
<MaterialTable
**Other Props Here**
components={{
Pagination: props => (
<StyledPagination
{...props}
labelRowsPerPage={<div>{props.labelRowsPerPage}</div>}
labelDisplayedRows={row => (
<div>{props.labelDisplayedRows(row)}</div>
)}
/>
)
}}
/>

我觉得这两个css选择器应该是多余的,但都不起作用。我觉得材料表正在覆盖它们,因为计算的字体大小是0.75rem .MuiTypography-caption。我也尝试过通过词根而不是标题进行造型,这也没有什么区别。

我已经能够为要显示的行数设置下拉选择器的样式,这似乎也适用于此。最初是从这种方法开始的,但也没有奏效。

最终用MuiThemeProvider解决了这个问题,我认为正常的ThemeProvider不能用Material-table

import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'
const theme = createMuiTheme({
overrides: {
MuiTypography: {
caption: {
fontSize: '1.5rem'
}
}
})

然后,

<MuiThemeProvider theme={theme}>
<MaterialTable />
</MuiThemeProvider>

虽然,这将风格任何与类MuiTypegraphy标题

相关内容

最新更新