簡體   English   中英

麻煩在材料表上設置 TablePagination to-from

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

我正在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 選擇器應該是多余的,但兩者都不起作用。 我覺得 material-table 正在覆蓋它們,因為計算出的字體大小是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>

雖然,這將使用 class MuiTypography-caption 設置任何樣式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM