Is it possible to implement a custom icon for pagination in Material UI?

Can I use a custom icon for pagination in material ui?

Find more information on Material UI Pagination in the official documentation here, and check out the CodeSandbox Demo here

I am interested in changing the default left and right chevron icons for navigation

You can view the desired custom icon here

Is there an existing method within material ui to accomplish this customization?

Answer №1

Although the icon cannot be changed directly, you have the flexibility to fully customize the pagination by utilizing the usePagination component.

https://codesandbox.io/s/material-demo-6b86k?fontsize=14&hidenavigation=1&theme=dark

<ul className={classes.ul}>
  {items.map(({ page, type, selected, ...item }, index) => {
    let children = null;

    if (type === 'start-ellipsis' || type === 'end-ellipsis') {
      children = '…';
    } else if (type === 'page') {
      children = (
        <IconButton  style={{ 
          fontWeight: selected ? 'bold' : undefined, 
         backgroundColor: selected ? 'rgba(0, 0, 0, 0.04)' : 'white',
          width: 50, 
          height:50
        }} {...item}>
          {page}
        </IconButton >
      );
    } else {
      children = (
        <IconButton  {...item}>
          {type === 'previous' ? <FastRewindIcon/> : <FastForwardIcon/>}
        </IconButton >
      );
    }
    return <li key={index} style={{ margin: 'auto 0'}}>{children}</li>;
  })}
</ul>

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

Autocomplete's `getOptionLabel` function unexpectedly returned an object ([object Object]) instead of the expected string

Currently delving into the world of ReactJS and working with @mui controls, specifically a Multiselect Dropdown with autocomplete feature. Here is the child component causing me some trouble, displaying the following error message: "index.js:1 Materi ...

What is a more effective choice for error handling - utilizing nextjs 'pages/_error.js' or implementing React ErrorBoundary?

I've been utilizing Next.js for a significant amount of time. Whenever an error occurs, I have typically depended on the _error.js page provided by Next.js. However, in their documentation here, they recommend using ErrorBoundary instead. Should I sti ...

Accessing Google authentication: A guide to programmatically prompting user consent and retrieving the CredentialResponse after successful login

Is there a way to trigger the Prompt for User Consent to open when clicking a custom HTML button instead of the Login iframe button rendered by Google? I am utilizing the Sign In With Google JavaScript API, and while I couldn't find a function to achi ...

Tips for ensuring consistent alignment of the final navigation item

I'm having trouble understanding why the layout collapses when I resize the window horizontally. I've attempted to adjust the width of the div and tried using display:block. My website is built with Bootstrap 3, although I don't believe that ...

Express Router Setup Error: The Router.use() method is expecting a middleware function, but instead received an undefined value

First and foremost, I want to clarify that I am well aware of the plethora of questions posed on this platform with a similar title. I have already attempted the suggestions provided there, but unfortunately, they either did not work for me or were too sp ...

Is it possible to limit the values of parameters with react-router?

Currently, I am in the process of developing a website using react and react-router. I have two different types of routes set up, as shown below: <Route name="products" path="/:type/*" handler={ ProductList } /> <Route name="generic-template" p ...

React Render causing Unexpected Token Issue

Having trouble with two React Apps - one main app and the other just a simple app with 1 component. I've imported the component package as node_module using npm link. Can someone guide me on how to resolve this issue? Here is the code for the SubApp ...

Updating the pointer style in Material UI version 5 for disabled MuiButton components

Is there a way to change the cursor and startIcon for disabled buttons in my theme without having to repeat it for each button? I've been trying to figure it out but can't seem to find a solution. The &:hover doesn't work as expected, an ...

Exploration of narrowing union types in React with TypeScript

import { Chip } from "@mui/material"; type CourseFilterChipsRangeType = { labels: { from: string; to: string }; values: { from: number; to: number }; toggler: (from: number, to: number) => void; }; type CourseFilterChipsCheckType = { ...

Displaying Props Information in a Modal Window using React

Currently venturing into the realm of React JS, where I am in the process of developing a sample eCommerce application for real-time use. However, I have hit a roadblock. In my Products List, there is a Buy button for each product. When clicking on this b ...

What is the best way to simulate useQuery from the react-fetching-library?

Hello, I'm looking for a way to mock useQuery in my project. I have a container component that is responsible for making API calls and a simple UI component to display the data to the user. Currently, I am encountering the following error: console.err ...

Scroll upwards within a nested div

Is there a way to smoothly animate the content of the inner div upward without requiring any button clicks? Also, is there a method to trigger an event once the animation has completed? ...

Show images from the Google Search API on a React component

I'm currently working on developing a custom image search application. The process involves a search text field where the user inputs their query, and through my Flask backend, I utilize the Google Image Search API to fetch relevant images. Upon clic ...

Unable to locate the React-dnd module

Just diving into React and I'm following this tutorial to successfully launch a fresh app. Managed to install: npm install --save react-dnd npm install --save react-dnd-html5-backend But when trying to include files from this tutorial import PropT ...

What could be causing the date input to appear oddly compressed solely on iPhone devices?

Click here to access the website, and view the code. The layout appears fine on desktop, as shown in this screenshot. However, on an iPhone, the date input gets collapsed despite being set to take up the full width of its parent div. Here is a screenshot ...

What purpose does the symbol '$' serve in React component properties?

While delving into the world of styled-component, I encountered some difficulties with the 'adapting based on props' aspect. import './App.css'; import styled from 'styled-components' const PrimaryButton = styled.button` co ...

Display an image overlay upon hovering over a div

I've developed an add-on for Elementor that includes a card with the following HTML markup: <div class="card"> <div class="header"> <img src="img.jpg"> < ...

Creating consistent row spacing between Bootstrap 5 rows that matches the spacing in Bootstrap 4

Is it possible to adjust the site.css file in order to achieve a similar row spacing effect as Bootstrap 5 when working with existing HTML code? ...

Side by side CSS list item with before element

Currently, I am working on displaying a list of 3 items where the list item number is larger than the actual text. I have been successful in achieving this part, but now my goal is to place them side by side. This is the code snippet I have implemented: ...

Solving the checkbox toggle challenge with recursive functions | Recursive checkbox challenge

I'm currently working on creating a checkbox tree with the following data structure for items const checkboxes = [{ field: 'ARTICLE', id: 41, name: 'Article', parentId: null, checked: false, children: [ ...