Tips for updating table pagination styles in Material-ui version 5.0 using React

I'm currently attempting to customize the table pagination in Material-ui V5.0 using React by adjusting the width, height, and color. However, I am facing an issue where the classes are not being accepted. The pagination relies on .MuiToolbar-root, so when I try to make changes via a .css file, it disrupts the MuiToolbar located at the top of the App page. Can someone provide guidance on how to implement these necessary changes without disrupting the Appbar at the top? Additionally, there is a need to modify the padding of .MuiTableCell-root as well. Below is my code for reference. Any help or suggestions would be greatly appreciated.

// Component SupplierTable

import React, {useState} from 'react'
import './SupplierTable.css';
import SupplierForm from './SupplierForm';
import PageHeader from '../components/PageHeader';
import FactoryIcon from '@mui/icons-material/Factory';
import * as supplierService from '../services/EmployeeService';
import Controls from "../components/controls/Controls";
import { InputAdornment } from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import AddIcon from '@mui/icons-material/Add';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import useTable from "../components/useTable";
import { makeStyles } from '@mui/styles';
import ModeEditOutlineIcon from '@mui/icons-material/ModeEditOutline';
import { TableRow, TableBody, TableCell } from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import Popup from '../components/Poup';
import Notification from '../components/Notifications';
import ConfirmDialog from '../components/ConfirmDialog';
import Grid from '@mui/material/Grid';

const useStyles = makeStyles(theme => ({
    overrides: {
        '&.MuiTablePagination-root':{
            width: '960px',
            height: '35px',
            backgroundColor: '#a9aeb3',
            color: 'rgb(41, 39, 39)',
            fontFamily: 'Arial, Helvetica, sansSerif',
            fontWeight: '700',
        }
    },

  pageContent: {
    margin: theme.spacing(1),
    padding: theme.spacing(3)
},
  searchInput: {
    width: '50%'
},
  newButton: {
    position: 'absolute',
    right: '0px'
},
  
}));

// Rest of the code follows...

Answer №1

Struggling with styling the pagination component myself, until I finally cracked it using sx.
Give this a shot:

 <TablePagination
    sx={{
      '.MuiTablePagination-toolbar': {
        backgroundColor: '#a9aeb3',
        width: '950px',
        color: 'rgb(41, 39, 39)',
        height: '35px',
      },
    }}
/>

Edit: I went all out on styling just to experiment a bit more. Check it out for some inspiration if there's anything specific you want to style.

 <Pagination
    {...mTablePaginationProps}
    rowsPerPage={rowsPerPage}
    onRowsPerPageChange={onRowsPerPageSelect}
    component="div"
    onPageChange={onPageChange}
    sx={{
      backgroundColor: 'red !important', // will be overridden if not important
      height: '70px',
      '.MuiInputBase-root': {
        backgroundColor: 'green',
      },
      '.MuiTablePagination-toolbar': {
        backgroundColor: 'pink',
        width: '950px',
        color: 'rgb(41, 39, 39)',
        height: '35px',
      },
      '.MuiBox-root': {
        backgroundColor: 'yellow',
        color: 'black',

        '& .MuiSvgIcon-root': {
          backgroundColor: 'purple',
          color: 'black',
        },
      },
    }}
    SelectProps={{
      ...mTablePaginationProps.SelectProps,
      MenuProps: {
        ...mTablePaginationProps.SelectProps.MenuProps,
        sx: {
          '.MuiPaper-root': {
            backgroundColor: 'rosybrown',
            color: 'black',
          },
          '.MuiTablePagination-menuItem': {
            ':hover': {
              backgroundColor: 'turquoise',
            },
            backgroundColor: 'yellow',
          },
          '.MuiTablePagination-menuItem.Mui-selected': {
            ':hover': {
              backgroundColor: 'blue',
            },
            backgroundColor: 'purple',
          },
        },
      },
    }}
  />

Here's how it looks in action: https://i.sstatic.net/qY49s.png

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

Exploring ways to access global window variables in React using JavaScript

I've been following the discussion on how to transfer variables from JavaScript to ReactJS. Here is my array of objects in JavaScript: window.dataArr = []; function makeJsObj(descr, currDate, done) { var data = {}; console.log(descr ...

Is there a way to implement Font Awesome Icons within CSS? I'm looking to incorporate an icon following a heading on my webpage

Can you guide me on how to incorporate Font Awesome Icons in CSS? I am looking to add an icon after a heading for better customization. Below is the code I have tried: <!DOCTYPE html> <html lang="en"> <head> <meta chars ...

The jQuery css method fails to apply styles to SVG circle elements

HTML: <div class="container"> <article class="caption"> <svg class="grid-point" width="100" height="100" style="height: 120px; width: 625px;"> <circle class="myPoint" cx="50" cy="50" r="5" fill="#80E1EE" / ...

locating the truth value of the data in an array retrieved from MongoDB

When returning from the mongoose find() function, I need to ensure that is_reqestor = true is checked. However, when updating the document, I pass the id which needs to be updated. let filter = { is_reqestor: true } if (!is ...

Problems with navigation alignment in Flask website due to HTML, CSS, and

Here's a snapshot of my current website design: website I'm attempting to place the Login & Sign up buttons in line with the rest of the navigation bar. I've tried various methods without success so far. My attempts include adjusting text a ...

Ensure that the div is completely filled by the button and input elements

My dilemma involves filling a div element with a button and an input field. I'm struggling to set the exact width of the button, which is causing the input field to overflow the parent container. Despite many attempts with various properties, includin ...

Discrepancy in Line Spacing in Internet Explorer 9 when Working with TextAreas

My TEXTAREA requires precise spacing, so I've set the formatting as shown below: TEXTAREA { font-family: Tahoma, Arial; font-size: 8pt; letter-spacing: 0px; line-height: 13px; } The issue arises when typing text into the textarea - the li ...

Troubleshooting border problems with Bootstrap 3 tables

Recently, I encountered a problem with the Bootstrap 3 table-bordered where the right border was not showing up. Below is the code snippet of my table: <table class="table table-bordered table-hover"> ... </table> Upon inspecting the table vi ...

Styling RDL files with CSS styling

How can I incorporate CSS styles into an SSRS report file? I'm looking for ways to edit the rdl file using any tool, without being limited to BIDS. Appreciate any insights or advice. Thank you! ...

Error: Attempting to access the value property of a null object within a React Form is not possible

I am currently developing a form that includes an HTML input field allowing only numbers or letters to be entered. The abbreviated version of my state interface is outlined below: interface State { location: string; startDate: Date; } To initiali ...

Unbinding or undoing an 'onclick' event when another 'onclick' event is triggered

I am facing an issue where clicking on elements with 'onclick' functions works as expected, but when I click on a different element with another 'onclick' function, the first one remains active. What I actually want is for the previous ...

Tips for resolving the Firefox display problem with input[type="file"] using CSS

After researching articles, it became clear to me that input[type="file"] displays differently across various web browsers. I am in need of a simple solution using only CSS to address this issue as I only require adjusting the width of the element. The w ...

Some Firebase functions are being blocked by CORS policy restrictions

When working with FireBase cloud functions, I encountered a CORS policy error that only occurs with certain methods. For instance, my GET and POST requests work perfectly fine, but when attempting to delete or edit an object, the CORS policy error immediat ...

Error message: Incompatibility with [email protected] on Mac during npm installation

I am currently in the process of setting up a react project. However, when I try to run npm install, I encounter the following error: npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for <a href="/cdn-cgi/l/email-protection" class="__cf_e ...

Web links do not adjust properly on mobile pages

Weblinks are causing issues with responsiveness on my website, as they are increasing the mobile page width and resulting in a poor user experience. I am currently using the Asona theme. Please help me resolve this issue - the weblinks are not wrapping t ...

Seeking the optimal method to efficiently create and revise items using GraphQL within Amplify and React

As I delve into Amplify, React, and GraphQL for the first time, I'm on a quest to unravel the best approach for creating mutations that establish an @hasMany relationship between multiple tables. In my project, which utilizes a multi-table solution fo ...

1. "Implementing initial state in React using ES6 classes"2. "Utilizing ES

The following class has been developed: class App extends Component{ render() { return ( <div className="app"></div> ); } } What is the correct way to set the initial state? Using getInitialState() ...

Is there a way to adjust the padding temporarily?

Important Note: Despite the misleading title of my question, it doesn't accurately reflect my actual query (sort of). Below is the code snippet in question: .one{ background-color: gray; } .two{ padding: 20px; } <div class = "one"> < ...

What is the best way to right-align navigation using bootstrap?

We are struggling to align our navigation items to the right side of our page. Despite using a container class and align-items-end, we have not been successful in achieving this. We must confess that this section is somewhat hastily put together, and we do ...

Strategies for aligning a div element in the middle of the screen

Positioned in the center of the current viewport, above all other elements. Compatible across different browsers without relying on third-party plugins, etc. Can be achieved using CSS or JavaScript UPDATE: I attempted to use Javascript's Sys.UI.Dom ...