``I'm having trouble with TablePagination styling on a material-table component. Anyone have

I am trying to customize the appearance of rows numbered from-to of x on a Material-Table, using the following code:

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 believe that both CSS selectors should be unnecessary, but none of them seem to work properly. It appears that material-table is overriding them since the computed font size shows as 0.75rem .MuiTypography-caption. I have also tried styling via the root rather than caption without any success.

Although I managed to style the dropdown selector for the number of rows displayed, I expected similar results here. Initially, I followed this approach but it did not yield the desired outcome either.

Answer №1

After some trial and error, I managed to resolve this issue using the MuiThemeProvider. It seems like the regular ThemeProvider wasn't compatible with Material-table.

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

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

Next step was to use:

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

It's worth noting that this approach will style any elements with the class MuiTypography-caption.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble adjusting the right-hand edges of form elements when using percentage widths

Simply put, the issue is this: Why doesn't the second row of elements, with widths of 35% and 55%, take up the same amount of the page's width as the first form element which uses 90%? I often have to adjust the percentages differently dependin ...

The issue with jspdf is that it is failing to generate PDF documents of

I'm currently developing a resume builder app using ReactJS. One of the functionalities I'm working on is enabling users to download their resumes as PDFs. However, I've encountered an issue with the generated PDFs when using jsPDF. The down ...

Safari experiencing a CSS issue not found in Chrome or Firefox

https://gist.github.com/2354116 When you check the link above in Chrome or Firefox, everything looks good. The divs at the bottom, including the headings and social icons, are centered within a container div without any issues. However, when viewed in Sa ...

Tips on saving a form submit button data to localStorage

As a newcomer, I am on a quest to make this function properly. My goal is to create a form where the submit button saves data to the localStorage. Here's what I have tried thus far. <script> function storeRecipe() { localStorage.setItem($(" ...

Disable the outer div scrolling in VueJS, but re-enable it once the inner div has reached the bottom of

I am currently working on a webpage that contains multiple divs stacked vertically. Here is the concept I am working with: Once the scrollbar reaches the bottom of the first div, the outer scrollbar will be disabled and the inner scrollbar will be enabled ...

There is currently no user present - utilize getServerSideProps in Next JS combined with AWS Amplify

I want to implement a user-authenticated GraphQL request on the serverside within the getServerSideProps function using AWS Amplify and Next JS. In my AWS Database, only users who are the designated owners of the document should be able to access the data ...

Unable to establish connection with "mqtt://test.mosquitto.org" using a React client

Looking to connect a React client app to a test server mosquitto. Here is the React code snippet involved: import mqtt from 'mqtt'; const connectToMqtt = (host, mqttOptions) => { setStatus('Connecting'); console ...

Apply the CSS style specifically to the initial row in the table

Is there a way to target the first row of a table with a different tr class using CSS? <div id="right"> <table> <tbody> <tr class="head"> <td >Date</td><td>Info</td><td>More</td> </tr> ...

Is there a way to make the <iframe> adjust its size as the element it contains grows, without

Seeking assistance with a specific issue. My goal is to have an iframe appear on hover of another element and expand with it. The problem I'm facing is that the iframe shows up quickly and extends beyond its parent container. Here's what I have: ...

Tips for separating provider and input components with React Hook Form

Currently, I am working on a project with Next 13.5 using react-hook-form and shadcn-ui. The issue that I have encountered is that creating a form involves too much redundant code. To address this, I abstracted the FormProvider and Input component. The pr ...

Dynamic TextField sizing

I am currently facing an issue while displaying data on a webpage using TextField component from @material-ui. Each record of data has varying lengths, making most values appear unattractive (occupying only 10% of the textfield width). Even though I am ut ...

Is there a way to modify the color of a Link component in React using Material-UI library?

I've encountered a problem trying to change the color of a Link inside a Button. Despite setting the secondary color for the Button, the color change doesn't seem to take effect, whereas it works fine for other components. <AppBar position=&a ...

How can jQuery be utilized to enlarge specific <li> elements that are aligned with the right side of the page?

I'm encountering issues with expanding list elements using jQuery. The lists consist of social media icon links that I would like to enlarge upon mouseover. The problem arises when enlarging the width of the li element, causing the ul to also expand. ...

Assist with automatically updating a field value based on user input during React Hook Form validation

TL;DR To see the working code, visit: https://codesandbox.io/s/stoic-beaver-ucydi The refactored version using React Hook Form can be found here: https://codesandbox.io/s/objective-cloud-bkunr?file=/src/ControlledTextField.tsx In Depth Explanation No Re ...

Repeating Fields in GraphQL Code Generation

Here is how I've set up my codegen.ts: import type { CodegenConfig } from '@graphql-codegen/cli'; const config: CodegenConfig = { overwrite: true, schema: 'http://localhost:3333/graphql', documents: 'libs/graphql/**/*.g ...

Hide Bootstrap columns for Printing

I am currently working on a webpage layout that consists of two columns. <div class="container"> <div class="row"> <div class="col-md-8 "></div> <div class="d-print-none col-md-4"></div> </div ...

Using JavaScript to print radio type buttons

Currently working on a web page and I've encountered a problem that's got me stumped. There are two sets of radio buttons - the first set for package dimensions and the second set for weight. The values from these buttons are assigned to variable ...

Encountered an ERESOLVE error when attempting to install a package, unable to resolve the dependency tree

After attempting to install the necessary dependencies for my project with npm install, an error message came up that I am unable to decipher: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: &l ...

JavaScript functioning in Firefox but not Chrome

Here is the code snippet in question: $('#ad img').each(function(){ if($(this).width() > 125){ $(this).height('auto'); $(this).width(125); } }); While this code works correctly in Firefox, it seems to have i ...

Trying out a React component that relies on parameters for connection

Having an issue while attempting to test a connected react component that requires a props.params.id in order to call action creators. During the testing process, when checking if the component is connected to the store, an error "Uncaught TypeError: Canno ...