Tips for personalizing the boxshadow in Material UI Card components

I'm having trouble customizing the box shadow for the Material UI card. I attempted to remove the default boxShadow and apply my own style to the cardWrapper I created, but it doesn't seem to be working. How can I add a custom boxShadow without using a div wrapper? Any guidance on how to achieve this would be greatly appreciated as I'm struggling to find a solution.

const useStyles = makeStyles({
  card: {
    paddingTop: 10,
    paddingBottom: 25,
    paddingLeft: 20,
    paddingRight: 20,
    boxShadow: "none",
  },
  cardWrapper: {
    shadowColor: "#000",
    shadowOffset: { width: 0, height: 1 },
    shadowOpacity: 0.8,
    shadowRadius: 2,
    elevation: 5,
  },
});
<div className={classes.cardWrapper}>
<Card className={classes.card}>
      <CardContent>
        <Typography className={classes.title} variant="h5" component="h2">
          Server Name
        </Typography>
      </CardContent>
</Card>
</div>

Answer №1

To begin, establish styles that are specific to the desired boxShadow within the useStyle section:

const useStyles = makeStyles({
  root: {
    minWidth: 275,
    border: "1px solid",
    padding: "10px",
    boxShadow: "5px 10px red"
  },
//additional styles and classes//
}

Next, implement these styles on the Card component:

<Card className={classes.root}>
  //include other sections of your code here//
</Card>

View it in action with this sandbox link.

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

Customize the MUI (JoyUI) Autocomplete feature in React using react-hook-form to display a unique value instead of the label

Currently, I am in the process of creating a form that includes JoyUI (material) autocomplete and react-hook-form functionality. The array of objects I am using for my options looks like this: [ { label: "Todo", param: "TODO" }, ...

Issue encountered while attempting to store quantity in localStorage

Currently, I am developing a shopping cart feature for my website and I would like to display the total quantity of items in the header. I have implemented useReducer and context to manage the state of my items within the application, which is functioning ...

Error occurs when attempting to read the 'map' properties of null because the JSON array is double nested

Within my code, I am attempting to access the URLs of two thumbnails in the JSON data below. Currently, I can only retrieve the information from the first array: <>{post.attributes.description}</> However, I am encountering difficulty retrievi ...

What causes the circular progress bar to disappear when hovering over the MUI React table?

My goal was to create a table with a CircularProgressBar that changes its background color from orange to dark blue when hovering over the row. However, despite my efforts, I couldn't get it to work as intended. Additionally, I wanted the progressBar ...

Storing files in DynamoDB using Reactjs is a convenient and efficient way

Is there a way to store resume files in an existing DynamoDB table that currently stores name and email information? I have attempted to do so using React's AWS package with the following code: <input name="my_file" onChange={e => upd ...

The Google Material UI TextField in Redux-Form does not automatically resize to fit multiple lines after being displayed

When my form is loaded hidden, the sizing of my multi-line Google Material UI TextField in react-redux does not adjust properly. To see the behavior in action, click here: https://codesandbox.io/s/redux-form-template-qe06o For a visual reference, check o ...

Enhancing Class Components with a different approach to styling rather than using makeStyles

I have come across examples that demonstrate how to utilize the makeStyles hook in order to style functional components in Material Design. However, since I am working with a class component, I am unable to use hooks. The code snippet often used for functi ...

Issue with TypeScript when using destructuring on an object

When attempting to destructure data from an object, I encountered the error message Property XXXX does not exist on type unknown. This issue arose while using React Router to retrieve data. let {decoded, reasonTypes, submissionDetails} = useRouteLoaderDa ...

Leverage the power of React in tandem with Express

My web site is being created using the Express framework on NodeJS (hosted on Heroku) and I'm utilizing the React framework to build my components. In my project, I have multiple HTML files containing div elements along with React components that can ...

What is the best way to pass query strings from React to the backend?

import React, { useEffect, useState } from "react"; import { Form, Row, Col, Button } from "react-bootstrap"; import { useParams, useNavigate } from "react-router-dom"; const FilterComponent = ({ categories, brands }) => { ...

Error message: "react-router typescript navigation version 0.13.3 - Unable to access 'router' property"

I'm currently in the process of porting an existing React project to TypeScript. Everything seems to be going smoothly, except for the Navigation mixin for react-router (version 0.13.3). I keep encountering an error message that says "Cannot read prop ...

Tips for establishing communication between a React Native webView and a React web application

I am currently working on establishing communication between a webView in react-native and a web-app created with React-360 (and React). I am utilizing the react-native-webview library and following a guide for creating this communication. You can find the ...

When working in React, I encountered a problem with the for of loop, as it returned an error stating "x is undefined." Although I could easily switch to using a simple for loop, I find the for of loop to

I'm encountering an issue when using a for of loop in React, as it gives me an error stating that "x is undefined". import { useEffect } from "react"; export default function HomeContent() { useEffect(() => { let content = document ...

How can we dynamically set input props based on the value of another prop state?

Looking to update inputProps in the textfield based on another prop. Here is an example: <TextField name={props.name} value={props.vals} inputProps={{autocapitalize:"characters", textTransform:"uppercase"}} onChange={props ...

Having trouble receiving any ringing status in nextjs while utilizing the getstream SDK

I attempted to integrate the getstream video SDK for calling from the caller to the callee. While I can successfully create calls from the caller side, I am not receiving any status updates about the call on the callee side. Below are my codes for the cal ...

React-hook-form being problematic: Radio button passing null value when selecting female option

Upon submission, I am encountering an issue where the value being retrieved is from the first option, resulting in a null value when selecting "female". However, the onChange function works correctly. <form onSubmit={handleSubmit(onSubmit)}> ...

Guide to modifying text color in a disabled Material-UI TextField | Material-UI version 5

How can I change the font color of a disabled MUI TextField to black for better visibility? See below for the code snippet: <TextField fullWidth variant="standard" size="small" id="id" name=&quo ...

Troubleshooting History.push issue in a Typescript and React project

Currently, I'm tackling a project using React and TypeScript, but I've encountered a problem. Whenever I attempt to execute a history.push function, it throws an error that reads: Uncaught (in promise) TypeError: history.push is not a function. ...

Using the Parallax Effect in React

I'm currently working on implementing a parallax effect in React and I've encountered an error that's giving me trouble: Below is the snippet of JavaScript code I have for the parallax effect: export const parallax = document.getElementsBy ...

Revolving mechanism within React.js

I am currently developing a lottery application using React.js that features a spinning wheel in SVG format. Users can spin the wheel and it smoothly stops at a random position generated by my application. https://i.stack.imgur.com/I7oFb.png To use the w ...