How can I change the padding that is being inherited from "@ .MuiAlert-icon"?

Is there a method to override the padding inherited from "@ .MuiAlert-icon"? The Chrome inspector indicates that the current padding is set to 7px.

.MuiAlert-icon {
    display: flex;
    opacity: 0.9;
    padding: 7px 0;
    font-size: 22px;
    margin-right: 12px;
}

I am attempting to override this padding using the makeStyles feature from Material UI. Below is the code I have implemented:

import Alert from "@material-ui/lab/Alert";
import Icon from "@material-ui/core/Icon";
import {  makeStyles } from "@material-ui/core";
  
const useStyles = makeStyles({
  icon: {
    overflow: 'visible',
    "& .MuiAlert-icon": {
      padding: 'none',
    }

  },
  outerTheme: {

  }
});
  
interface idVerifyProps {
    status: string; 
  }


const IDverify = ({ status }: idVerifyProps) => {
  const classes = useStyles();
  const svgIcon = (
    <Icon className={classes.icon}>
      <img alt="edit" src="../../../checkIcon.png" />
    </Icon>
  );
    return (
      <div >
        <Alert severity="error" style={{ backgroundColor: "#E6FFE9",}} icon={svgIcon}>{status}</Alert>
      </div>
    );
  };
  export default IDverify;

I'm unsure of where the 7px padding originates from, but it appears to be a default setting within the Icon component. My objective is to simply eliminate this padding by setting it to zero.

Answer №1

Make sure to assign the desired class to the icon in classes={{ icon: <your_class> }}

alertIcon: {
  padding: 0,
},
return (
      <div >
         <Alert
            severity="error"
            style={{ backgroundColor: "#E6FFE9",}}
            icon={svgIcon}
            classes={{ icon: classes.alertIcon }}
         >
           {status}
         </Alert>
      </div>
    );

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

Display the image regardless of whether the component is currently visible

I need help with my Vue.js web application that includes a side navigation menu component. This component uses conditional rendering to display only when necessary. Within the component, there is an image for the close button of the side menu. <transiti ...

Issues with AngularJS functionality – $route.reload() not functioning as expected

I'm attempting to refresh the page using $route.reload(): var App = angular.module("App", ["ngRoute"]); var idx = 0; App.controller("List", function ($scope, $route) { $scope.changeWallet = function (index) { idx = index; $r ...

Fetching data from a database for Vue.js using the Summernote editor

I previously inquired about integrating summernote with vue.js and received a helpful response here. It worked seamlessly with v-model binding. However, I encountered an issue when attempting to load data from the database for an edit page. The data was n ...

How can I go about refreshing my mapbox gl source data?

Hey there, I'm encountering an issue when attempting to update my mapbox source on click. I currently have two sources (cells, heatmap), and I am trying to add a new source using this code snippet: this.map.addSource("points", { type: "geojson", ...

AngularJS Expandable Table - Unlocking Limitless Possibilities

Take a look at the code snippet below: <tbody> <tr ng-repeat-start="ticket in tickets"> <td> <button ng-if="ticket.expanded" ng-click="ticket.expanded = false">-</button> <button ng-if="!t ...

JavaScript's asynchronous callbacks

As a PHP developer delving into the world of NodeJS, I find myself struggling to fully grasp the concept of asynchrony in JavaScript/Node. Consider this example with ExpressJS: router.get('/:id', function (req, res, next) { var id = req.par ...

I seem to be having trouble using my markers on my istamap

function initialize() { var mapProp = { center:new google.maps.LatLng(51.508742,-0.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("googleMap"),mapProp); var marker = new ...

What is the reason behind the linking or appearance together of src/pages in Visual Studio Code?

As I venture into the world of Visual Studio Code (VSC) and follow a Gatsby tutorial, I've noticed that every time I create a new directory, VSC seems to automatically link src/pages together. However, my preference is for pages to be a subfolder of s ...

Navigating between two table components in React JS

I am a beginner in the world of React and I am struggling with switching between these two tables. Despite consulting the documentation for inline conditional statements, I still couldn't figure it out. My goal is to have the tables switch after click ...

What could be the reason for Firefox cutting off circular PNG images at the bottom?

Can you explain why Firefox is cutting off circular png images at the bottom of this page: It's strange that IE 10 and Chrome don't have this issue with cropping the images. ...

Showing the number of guilds as an action displayed on the screen

I'm trying to make my bot say "Watching (number of servers it's in) servers!" with this code: const activities_list = [ "with the &help command.", "with the developers console", "with some code", "with JavaScript", client.guilds. ...

Using a function as an argument to handle the onClick event

I have a function that generates a React.ReactElement object. I need to provide this function with another function that will be triggered by an onClick event on a button. This is how I call the main function: this._createInjurySection1Drawer([{innerDra ...

Can you tell me the proper term for the element that allows CSS properties to be changed after a link has been clicked?

I have integrated a horizontal scrolling date selector on my website, and it is functioning well. However, I am facing an issue while trying to change the CSS properties of a clicked date link using jQuery. Despite successfully firing the click event, I am ...

Managing array elements in React: removing and duplicating items

One of my tasks is to incorporate a copy and delete button within a table. My goal is to pass the index from the map to the delete and copy onclick functions, however, I am encountering an issue where copying a row results in it having the same index as th ...

Tips for customizing the background color and image of a toaster

Looking to modify the background color and image based on the else condition (toaster.error) success: function (data) { if (data.message != ""){ toastr.success(data.message); ...

Animations do not trigger with content changes in AngularJS ngIf

According to the Angular documentation on ngIf, animations occur just after the contents change and a new DOM element is created and injected into the ngIf container. Animations In my experience, I have encountered issues with this behavior. To demonstra ...

Create an array by copying elements from another array object

My goal is to merge the data from two arrays, array1 and array2, into a new array called array3. Here's how I want it structured: array 1 objects: userName, userId array 2 objects: userId, msg I aim to obtain an array3 consisting of: userId, userNa ...

Execute a Node script using PHP exec, retrieve the data in PHP, and then apply the finally method

I'm working on a PHP script that utilizes the exec function to run a Node script and then return some data back to the PHP script. The challenge I'm facing is finding a way to send the data back to PHP without having to wait for the cleanup code ...

Tips for creating a unique scroll page arrow button with adjustable thickness?

Seeking guidance on how to adjust the thickness of the arrow used as a scroll button on my website. I am aiming for a similar look to the arrow on this particular website: example of arrow https://i.sstatic.net/wO5br.png To view my code, please visit: Cod ...

Using JavaScript to parse JSON data generated by PHP using an echo statement may result in an error, while

I am facing an issue with parsing a JSON string retrieved from PHP when the page loads. It's strange that if I send an AJAX request to the same function, the parsing is successful without any errors. The problem arises when I attempt to do this: JSON ...