Material-UI now offers the ability to customize the shadows array within createMuiTheme to support up to 25 different elevations

Currently working on removing shadows in the Material-UI theme.

Came across this useful solution that fixed the issue. However, encountered an error related to this topic.

const theme = createMuiTheme({
  palette: {
    primary: {
      light: red[300],
      main: red[500],
      dark: red[700]
    },
    secondary: {
      light: red.A200,
      main: red.A400,
      dark: red.A700
    }
  },
  shadows: ['none']
});

Error:

browser.js:49 Warning: Material-UI: the shadows array provided to createMuiTheme should support 25 elevations.

Discovered a potential solution but did not find it helpful: https://github.com/mui-org/material-ui/issues/8289

Answer №1

It appears that your Theme needs to include a minimum of 25 shadows in order to achieve the desired effect similar to Material UI. While I would advise against removing the shadows if you want to adhere to Material UI standards, a simple solution could be to set all levels of elevation to none.

const theme = createMuiTheme({
  palette: {
    primary: {
      light: red[300],
      main: red[500],
      dark: red[700]
    },
    secondary: {
      light: red.A200,
      main: red.A400,
      dark: red.A700
    }
  },
  shadows: Array(25).fill('none')
});

This adjustment should meet the criteria.

UPDATE:

Just a reminder from Dave, ensure to cast if you are using TypeScript:

shadows: Array(25).fill('none') as Shadows

Answer №2

In my opinion, the most effective approach is to utilize overrides when dealing with box shadows. The specific shadow you wish to eliminate will determine which override to use.

const theme = createMuiTheme({
  palette: {
    primary: {
      light: red[300],
      main: red[500],
      dark: red[700]
    },
    secondary: {
      light: red.A200,
      main: red.A400,
      dark: red.A700
    }
  },
  overrides: {
    MuiAppBar: {
      root: {
        'box-shadow':'none'
      }
    }
  }  
});

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

Vue component updating its model only upon input element losing focus

I'm a beginner with vue and I'm currently working on incorporating an ajax search feature that triggers when a keyup event occurs. I have noticed that the model only updates when the input element loses focus. Sample HTML Code: <input name=" ...

Selecting options in an input field using AngularJS

In my AngularJS template, I have the code snippet below: <input type="number" id="exercise-log-duration-hours-{{ ::$id }}" class="form-control" ng-model="$ctrl.workoutHours" ng-change="$ctrl.updateHours($ctrl.workoutHours)" name ...

Is it possible to utilize an npm package in TypeScript without a d.ts definition file?

Is it possible to use an npm package in TypeScript and Node.js without a .d.ts definition file? If so, how can I make it work? Currently, my code looks like this and I'm getting an error that says "cannot find module 'node-rest-client'" bec ...

What about nested elements with percentages, set positions, and fixed placements?

Picture: https://i.sstatic.net/KFNR1.png I am working on a design with a yellow container div that I want to keep at 50% width of the window. Inside this container is a purple image div that stretches to 100% of the parent container's width, and ther ...

Choosing one item from an array to showcase in a view [Angular]

I've previously inquired about this issue without success. My current challenge involves a store app created with AngularJS. I am trying to implement a feature where clicking on an item will open it in a separate "item" view, displaying only the info ...

Capturing information within a jQuery function by accessing data from another function

Can data be collected from another function while the function is running? // Custom Function function getData(){ var name = 'tom'; return name } // Main Target Area $('.myDiv').click(function(){ // I need to retrieve dat ...

The world of coding comes alive with Quartz Composer JavaScript

Seeking assistance as I navigate through a challenging project. Any help would be greatly appreciated. Thanks in advance! I have a Quartz Composition where I aim to incorporate a Streetview from Google Maps and control the navigation, but I'm unsure ...

Sort users by their data attribute using jQuery

I need to sort users based on their data attribute. Within the main div called user-append, I have a variable number of users retrieved from an ajax get request. It could be 3 users or even up to 100, it's dynamic. Here is the structure with one user ...

Attempting to fetch JSON information but encountering an error message stating "not a valid function."

I have been working on developing a programmer job board app and I am currently facing an issue with displaying JSON data on the main page. My goal is to eventually render the data, but for now, I just want to ensure that it appears in JSON format so that ...

Issue encountered when attempting to redirect following a jQuery Ajax request

I attempted to create a redirection mechanism upon receiving a successful response from the server. I followed instructions here, but unfortunately, I couldn't get it to work as intended. Below is the function responsible for sending data to the serv ...

Is there a way in MVC3 / .net4 to convert a JSON formatted JavaScript array into a C# string array?

I am facing a challenge with my MVC3/.Net service where it is receiving arguments in the form of a JSONified Javascript array. I want to convert them into a C# array of strings. Is there a built-in solution available for this task, or do I need to create ...

Is there a way to automatically refresh a page as soon as it is accessed?

My goal is to create a page refresh effect (similar to pressing Command+R on Mac OS) when navigating to a certain page. For instance: Currently, when I navigate from "abc.com/login" to "abc.com/dashboard" after successfully logging in, the transition occ ...

Attempting to remove certain selected elements by using jQuery

Struggling to grasp how to delete an element using jQuery. Currently working on a prototype shopping list application where adding items is smooth sailing, but removing checked items has become quite the challenge. Any insights or guidance? jQuery(docume ...

What could be the reason for encountering TypeScript within the Vue.js source code?

While exploring the vue.js source code, I stumbled upon some unfamiliar syntax that turned out to be TypeScript after further investigation. What baffled me was finding this TypeScript syntax within a ".js" file, when my understanding is that TypeScript ...

Add a container element resembling a div inside a table without implementing the table layout

I am working with a table that is rendered by DataTable, and I have the requirement to dynamically append new elements inside the table like this: The dark grey area represents the new DOM elements that need to be inserted dynamically. The first row cont ...

What is the best way to prevent a folder from being included in the next js build process while still allowing

I am faced with a challenge involving a collection of JSON files in a folder. I need to prevent this folder from being included in the build process as it would inflate the size of the build. However, I still require access to the data stored in these file ...

When using PHP, JavaScript, and HTML, you can trigger an image upload immediately after choosing a file using the

I currently have a small form with two buttons - one for browsing and another for uploading an image. I feel that having two separate buttons for this purpose is unnecessary. Is there a way to combine the browse and upload functions into just one button? ...

What is the method for retrieving the currently selected value in a MultiColumnComboBox within Kendo for Angular?

Check out this live example created by the official Telerik team: I need to extract the id (referenced in contacts.ts) of the currently selected employee when clicking on them. How can I access this information to use in another function? ...

In Angular, you can easily modify and refresh an array item that is sourced from a JSON file by following these steps

Currently, I am working on implementing an edit functionality that will update the object by adding new data and deleting the old data upon updating. Specifically, I am focusing on editing and updating only the comments$. Although I am able to retrieve th ...

Is it possible to refresh the Dictionary using data from localStorage?

I attempted to retrieve all key/value pairs from the localStorage and use them to update my dictionary named keywordDict in the following manner: $(document).ready(function() { var store = allStorage(); console.log(store); $.ajax({ url: '/m ...