Reputation: 275
I am using Material UI's pagination component and would like the text portion of the component to be grey. The color i want is white for action button and grey for text portion. Is there any way I can do this in which i decide the color of the text portion? Essentially would like the text to be grey like the left action arrow in photo.
import React from 'react';
import TablePagination from '@material-ui/core/TablePagination';
import PropTypes from 'prop-types';
import { withTheme, withStyles } from '@material-ui/core/styles';
const styles = theme => ({
root: {
flexShrink: 0,
color: theme.palette.common.white,
marginLeft: theme.spacing.unit * 2.5,
},
});
const PortfolioPagination = ({
numOfItems, rowsPerPage, page, handleChangePage, classes
}) => {
return (
<div >
<TablePagination
component="div"
className={classes.root}
count={numOfItems}
page={page}
onChangePage={handleChangePage}
rowsPerPageOptions={[]}
rowsPerPage={rowsPerPage} />
</div>
);
};
PortfolioPagination.defaultProps = {
};
PortfolioPagination.propTypes = {
classes: PropTypes.object.isRequired,
numOfItems: PropTypes.number.isRequired,
rowsPerPage: PropTypes.number.isRequired,
page: PropTypes.number.isRequired,
handleChangePage: PropTypes.func.isRequired,
};
export default withTheme()(withStyles(styles)(PortfolioPagination));
Upvotes: 0
Views: 2136
Reputation: 1180
I recently came across the same issue and solved it by using the style customization points of the component. Here is an example:
import { TablePagination } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles((theme) => ({
color: {
color: "green"
},
leftIconButton: {
color: "blue !important"
},
rightIconButton: {
color: "red !important"
}
}));
export default function App() {
const classes = useStyles();
return (
<div className="App">
<TablePagination
classes={{
root: classes.color
}}
backIconButtonProps={{ className: classes.leftIconButton }}
nextIconButtonProps={{ className: classes.rightIconButton }}
rowsPerPageOptions={5}
component="div"
count={10}
rowsPerPage={5}
page={1}
onChangePage={() => {}}
onChangeRowsPerPage={() => {}}
/>{" "}
</div>
);
}
Upvotes: 1