Skip to content
the poor coder

how to change mui ripple color

Poor Man
Published
Reading time
1 min read
On this page

How to Change MUI Ripple Color#

If you are using Material-UI Library (MUI) for your project, you might have noticed that the ripple effect on buttons and other components is in the default blue color. However, you can easily change the ripple color to match your project's design. Let me show you how.

Method 1: Using Theme Provider#

The easiest way to change the ripple color is by using Theme Provider in MUI. Here's how you can do it:

Text

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

const theme = createMuiTheme({
  palette: {
    primary: {
      main: '#ff0000' // Your desired color
    }
  }
})

function App() {
  return (
    <ThemeProvider theme={theme}>
      <Button>My Button</Button>
    </ThemeProvider>
  )
}

In the code above, we have created a custom theme using the createMuiTheme function and set the primary color to red. Then we have wrapped our button component with the ThemeProvider component and passed our custom theme as the prop.

Method 2: Using CSS#

If you prefer using CSS to change the ripple color, you can do it by targeting the .MuiTouchRipple-root class. Here's an example:

Text

.MuiTouchRipple-root {
  background-color: #ff0000; // Your desired color
}

In the code above, we have targeted the .MuiTouchRipple-root class and set the background color to red. You can add this CSS to your global stylesheet or add it to the component's style prop.

That's it! You have successfully changed the ripple color in MUI. You can use either of the methods mentioned above based on your preference and project requirements.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC