简体   繁体   English

麻烦在材料表上设置 TablePagination to-from

[英]Trouble styling TablePagination to-from on material-table

I am attempting to style the from-to of x rows number on a Material-Table, via我正在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>
              )}
            />
          )
        }}
/>

I feel like those two css selectors should be redundant, but neither is working.我觉得这两个 css 选择器应该是多余的,但两者都不起作用。 I feel like material-table is overriding them as the computed font size is 0.75rem.MuiTypography-caption .我觉得 material-table 正在覆盖它们,因为计算出的字体大小是0.75rem.MuiTypography-caption Have also attempted styling via the root rather than caption with no difference there either.还尝试通过根而不是标题进行样式设置,那里也没有区别。

I have been able to style the dropdown selector for number of rows to display, which seems like the same should apply to this.我已经能够为要显示的行数设置下拉选择器的样式,这似乎同样适用于此。 Originally started with this approach, which also did not work.最初是用这种方法开始的,这也不起作用。

Ended up solving this with MuiThemeProvider , I dont think the normal ThemeProvider is working with Material-table最终用MuiThemeProvider解决了这个问题,我不认为普通的ThemeProvider正在使用Material-table

import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'

const theme = createMuiTheme({
  overrides: {
        MuiTypography: {
          caption: {
            fontSize: '1.5rem'
          }
  }
})

then,然后,

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

Although, this will style anything with class MuiTypography-caption虽然,这将使用 class MuiTypography-caption 设置任何样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM