Tips on concealing mui TextField label

In the process of developing a Nextjs app, I have created a dashboard navbar using mui components. The navbar includes an interactive notification <IconButton> that triggers a notification box built with standard HTML and CSS.

dashboard-navbar.js:

import NotificationBox from "./notification-box/notification-box";
//...
export const DashboardNavbar = (props) => {

 const [down, setDown] = useState(false);
 const toggleDown = () => {
   setDown(!down);
 };
//...
  return (
    <>
      <NotificationBox down={down} notifications={props.notifications} />
      <DashboardNavbarRoot>
          <div style={{ display: "flex", gap: "25px" }}>
            <div style={{ transform: "translate(0,18px)" }}>
              //...
              <IconButton
                aria-label="more"
                id="long-button"
                onClick={toggleDown}
                style={{ transform: "translate(20px,-15px)" }}
              >
                <Badge badgeContent={0} color="primary" variant="dot">
                  <BellIcon fontSize="small" />
                </Badge>
              </IconButton>
             
            </div>
          //...
          </div>
      </DashboardNavbarRoot>
    </>
  );
}

notification-box.js:

import classes from "./notification-box.module.css";

export const NotificationBox = ({ down, notifications }) => {
  var box = document.getElementById("box");
  if (down) {
    box.style.height = "0px";
    box.style.opacity = 0;
  } else {
    box.style.height = "510px";
    box.style.opacity = 1;
  }
  return (
    <div className={classes.notifiBox} id="box">
      <h2>
        Notifications <span>{notifications.length}</span>
      </h2>
      {notifications.map((notification, index) => (
        <div key={index} className={classes.notifiItem}>
          <img src={notification.img} alt="img" />
          <div className={classes.text}>
            <h4>{notification.title}</h4>
            <p>{notification.content}</p>
          </div>
        </div>
      ))}
    </div>
  );
};

notification-box.module.css:

  .notifiBox {
    /* background-color: white; */
    width: 300px;
    height: 0px;
    position: absolute;
    top: 63px;
    right: 35px;
    transition: 1s opacity, 250ms height;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  }
  .notifiItem {
    display: flex;
    border-bottom: 1px solid #eee;
    padding: 15px 5px;
    margin-bottom: 15px;
    cursor: pointer;
  }
  .notifiItem:hover {
    background-color: #eee;
  }
  .notifiBox h2 {
    font-size: 14px;
    padding: 10px;
    border-bottom: 1px solid #eee;
    color: #999;
  }
  .notifiBox h2 span {
    color: #f00;
  }
  .notifiItem img {
    display: block;
    width: 50px;
    margin-right: 10px;
    border-radius: 50%;
  }
  .notifiItem .text h4 {
    color: #777;
    font-size: 16px;
    margin-top: 10px;
  }
  .notifiItem .text p {
    color: #aaa;
    font-size: 12px;
  }

result:: https://i.sstatic.net/kSo2E.jpg

I experimented with adding a background-color property to the notifiBox class and setting it to white, which improved the appearance but the issue of hiding the mui textField label persistently remained unresolved:

https://i.sstatic.net/xbHg6.jpg

Answer №1

The label in the Mui Textfield has a z-index property applied to it, causing it to appear as if it is overlaying the input border.

To resolve this issue, you can increase the z-index value of the notifiBox class, which will then hide the label element.

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

Issue with assigning material to a three.js object!

Being new to three.js, I have recently started exploring it. However, I am facing an issue where I am unable to assign a material to an object. var objloader=new THREE.OBJLoader(); var material=new THREE.MeshNormalMaterial(); objloader.load('man.obj& ...

What are the steps to utilize vue.js for dynamically adjusting my sidebar based on a URL input?

Greetings to the amazing community of Vue.js enthusiasts, I am a novice looking to develop a single-page web application using vue.js. This application will consist of a fixed header and dynamic body content that changes based on user interactions. Here&a ...

Exploring image retrieval documents in PhoneGap

In the process of developing a PhoneGap application that involves capturing images using the camera and subsequently uploading them, I have encountered an issue. In PhoneGap, there are two modes for camera operation: raw base64-encoded data or a file URI. ...

Determine the coordinates of the visible portion of an overflowed (zoomed in) image on a mobile screen using HTML

Currently, I am developing a mobile application using HTML / JavaScript. In this application, users have the ability to pinch-in (zoom in) on an image to focus on a specific part. When zooming in, only a portion of the image is visible, not the entire imag ...

Using axios to pass FormData as a parameter in a post request

I am facing a challenge while trying to upload employee information through a form that requires strings and a picture. I am utilizing axios and node.js for this task, but upon hitting the submit button, I encounter an error (500): message Employees v ...

Animating the height of a container with unspecified initial and final heights using CSS transformations

I am faced with a challenge in styling a container that dynamically changes its height based on the content it holds. The issue arises when I want to add a transition effect to this dynamic height change. Since the height is determined by the changing text ...

Tips for styling HTML arrays

I have a large form and I want to format my HTML form into an array. The issue I'm facing is how can I assign numerical values to stations like 0, 1, 2, 3, ... as demonstrated below? $processes["stations"] = array( "0" => array( ...

Comparing Fetch Request and WebSocket: Determining the Quickest Option

When sending the same data in both Fetch and WebSocket, there is a noticeable speed difference: HTTP takes 29 seconds to transfer around 200 MB. WebSocket takes 6 seconds to transfer around 200 MB. An Interesting Observation: Why does WebSocket outperfo ...

Tips for identifying functions that return objects

I'm trying to figure out how to extract the type from the object returned by a specific function. The function returns an object with two keys: X and Y. In my getItem function, I only need the type of X. I don't want to use the interface Selecte ...

Tips for resizing all elements in Material-UI to fit your design requirements

I have been working on developing an app and encountering a frustrating issue. When I visit the library page (https://material-ui.com/components/buttons/#button), all the components are displayed in a desirable size. https://i.stack.imgur.com/DbqS6.png ht ...

What is the most efficient way to dynamically insert a space, break, or div at a specific height?

My goal is to generate a PDF from a React app that includes multiple components. The number of components can vary from 4 to 12, and the height of the components also changes based on content from the store. I am looking for a solution where every 900px ( ...

Bizarre error when injecting Factory into Controller in AngularJS

After scouring through countless posts on various forums, I have yet to find a solution to my unique problem. I find myself in a peculiar situation where I am trying to inject a Factory into a Controller, and despite everything appearing to be in order, i ...

Exploring the differences between a callback function and an asynchronous

In the code snippet below, I have implemented handling for SIGINT and SIGTERM signals in a node.js application. // quit on ctrl+c when running docker in terminal process.on('SIGINT', async () => { console.info('Got SIGINT (aka ctrl+c in ...

Position of the helper text in Material-UI TextField using React.js

Currently, I am developing a project using React JS and incorporating the Material UI library to manipulate table rows. However, I'm facing an issue with aligning text fields alongside other fields. Whenever the helper text appears, the text field see ...

ReactJS mixes up fetch URLs with another fetch_WRONG_FETCH

I have a fetch function in my Home component: export default function Home() { const { rootUrl } = useContext(UserContext); useEffect(() => { fetch(`${rootUrl}/api/products/featuredProducts`) .then((result) => result.json()) .then ...

Issue with displaying progress bar value when using AngularJS on Microsoft Edge with HTML5

I'm facing an issue with a progress bar on my website. The maximum value is set to 100, and the dynamic value is set on page load. It functions properly on Firefox, Chrome, and Safari, but on Microsoft Edge, the value always shows as 0. Here's th ...

Transforming Javascript into Typescript with node modules in Visual Studio 2015

After developing a JavaScript web app using npm and webpack, I successfully converted all the .js files to .ts using the PowerShell command found here. Now, I am looking to transition to a VS2015 TypeScript project but struggling to find guidance on how ...

Having an issue with my code in angular 12 where I am unable to successfully call an API to retrieve a token, and then pass that token to another API for further processing

Here is the code snippet containing two methods: getToken and validateuser. I am fetching the token from getToken and passing it as a parameter to validateuser. However, before retrieving the token, my second API call is being executed. ...

Modifying the key of a JSON object can result in the alteration of other associated values as well

Overview: A JSON Object var JSON_OBJECT = []; has been defined as a global variable. [ { "user_id": "123", "AF": [ { "formula_type": 0, "lag": 0 } ], "Trend": [ { "is_active": 0 ...

Updating a marker's latitude and longitude using Laravel, Google API, and Ajax: A step-by-step guide

I'm struggling with sending the marker coordinates to a controller using ajax. I have named my routes 'update-marker-position' and included csrf_token(), but I am still seeing an error message in the logs. In my web.php file: Route::post(&a ...