``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

What are the different ways to customize the indicator color of React Material UI Tabs using hex

Just got my hands on this amazing Material UI component <Tabs textColor="primary" indicatorColor="primary" > <Tab label="All Issues"/> </Tabs> The documentation states that indicatorColor and textColor can only be set to ' ...

Issue when attempting to animate an SVG point using translateX transformation

I am attempting to create a basic animation using the translate X property on a section of my svg when hovering over the element. Here is the code I have so far: <html> <style> .big-dot:hover { transform: translateX(20px); animat ...

Changing the Material UI imported Icon on click - a step-by-step guide

Hey there, I'm currently working with React JS and Redux. I have a challenge where I need to change the star outline icon to a filled star icon on click. The icon is located just after emailRow in the emailRow__options section. Can someone assist me w ...

What is preventing the addition of links to the navigation bar when using a sticky navigation bar?

Currently, I am in the process of developing a blog website using Django. One of the features I have successfully implemented is a sticky navigation bar. However, I am facing a challenge with adding links to the menu on the navigation bar due to existing ...

Disabling the slide effect in Material UI Slide component by adjusting its behavior according to the component's state

Incorporating a menu into a Slide component has been quite a challenge. Here's the code I've been working on: return( <Slide direction="down" in={showNavState} > <AppBar position="absolute" className={classes.bgColor} > ...

In IE9, users can select background elements by clicking on specifically positioned links

Trying to turn an li element into a clickable link by overlaying it with an a element set to 100% height and width. While this solution works in Chrome and FF, IE9 is causing issues as other elements behind the link remain selectable, rendering the link un ...

Upon concatenation, the screen automatically returns to the beginning of the page

I've set up a page with a list of items, and at the bottom there's a handy "Load more" button that fetches new items to add on top of the existing list: handleLoadProducts = (append = false) => { this.setState({ isLoading: true, ...

Is there a way to simply send the data to the API endpoint without having Django allauth url fetching from react and calling the signup view form?

For my project, I am utilizing React as a standalone Single Page Application (SPA) that connects to a Django backend with allauth for authentication management. When I enter the URL on my local browser (192.168.86.28:8000/accounts/signup/ or 127.0.0.1:8000 ...

Components can be iterated over without the use of arrays

In my component, I have a render that generates multiple components and I need some of them to be repeated. The issue I am facing is that when I create an HTML render, the variable is not being processed and it just displays as text. Although the actual c ...

"Interactive table feature allowing for scrolling, with anchored headers and columns, as well as the option to fix

I'm in need of a table that has certain requirements, as shown in the image. https://i.stack.imgur.com/Z6DMx.png The specific criteria include: The header row (initially blurred) should remain fixed when scrolling down the table The first column s ...

Having Trouble Resending OTP through Firebase for Phone Number Authentication

In the process of implementing a resend OTP feature with Firebase Authentication for phone number sign-in on my web application, I am encountering difficulties. Despite using the Firebase JavaScript SDK and following the documentation to configure the reCA ...

ReactJS: Trouble encountered while parsing information from JSON data

Currently, I am facing an issue while trying to pass data from my JSON file to my ReactJS application. The error message that I am encountering is as follows: TypeError: Cannot read property 'mainPage' of undefined Upon console.logging siteDa ...

Using the mailto functionality with Material UI

Need help with using the mailto feature in Material UI. I attempted to include a simple <ListItem button component={Link} mailto='' /> within a ListItem, but it did not work. I also experimented with: <ListItem button > <i cla ...

Press the key to navigate to a different page

I have an input field for a search box. I want it so that when I enter my search query and press enter, the page navigates to another page with the value of the input included in the URL as a query string. How can I achieve this functionality? Thank you ...

Customize the label and value in Material UI React Autocomplete

If you visit this link, you can see an example of what I'm trying to achieve. My goal is to have the option label and value be different from each other. In the provided example, the following code snippet is used: const defaultProps = { ...

Refreshing child routes in a SPA application using NGINX

I built a Single Page Application using ReactJS. It features an index view at /myapp where users can see a list of cards. Clicking on a card takes them to different pages via routes like /myapp/item, /myapp/itemXX. Everything works smoothly when accessed f ...

What is the best way to make an attribute in an interface mandatory only when another attribute is set to true

How can a relative be made required only when another attribute is true? For Example: interface ITesteProps { required: boolean content{!required && '?'}: string } I understand that this code is not valid. Is it possible to make the ...

Issues with jQuery animate.css functionality specifically occurring on Firefox browser

As a beginner in jQuery, I have been exploring different animations and recently came across an issue with Firefox compatibility. I discovered the animate.css library, and decided to incorporate its animations into text captions on a slider using the Soli ...

Using mySQL to power your server in a React Native application

Is Realm sufficient as a local database for app development, or is MySQL required for the server database? ...

When attempting to insert a date into a MySQL database using React.js, I encountered an issue with the date format

Hey everyone, I have set the input date to dd/mm/yyyy format using moment(donors.donateDate).format('DD-MM-YYYY'). However, when I click the submit button, an error is displayed in the console stating: The specified value "23-03-2022" ...