Eliminate unnecessary transparency in React Material UI Tooltip / Popper by adjusting opacity restrictions

Looking to integrate the Tooltip component from the React Material UI Library into my project. The code snippet I am using is as follows:

<WhiteOnDarkGreyTooltipWithControls
  disableTouchListener
  disableFocusListener
  title={
    <Text selectable={false} style={[styles.ratedIndicatorTextColor]}>
      {"Game Completion Rate"}
    </Text>
  }
  placement={"bottom"}
  disablePortal={true}
>
  <Text selectable={false}>GCR</Text>
</WhiteOnDarkGreyTooltipWithControls>;

The structure of the

WhiteOnDarkGreyTooltipWithControls
component looks like this:

import withStyles from "@material-ui/core/styles/withStyles";
import Tooltip from "@material-ui/core/Tooltip";
import React from "react";

export const WhiteOnDarkGreyTooltip = withStyles({
  tooltip: {
    color: "E0E0E0",
    backgroundColor: "#404040",
    borderRadius: 2,
    maxWidth: 200,
    textAlign: "center",
    fontWeight: 900,
    padding: 8,
    marginTop: 5,
    opacity: 1
  },
  popper: {
    opacity: 1
  }
})(Tooltip);

export class WhiteOnDarkGreyTooltipWithControls extends React.Component {
  state = { open: this.props.open };

  render = () => (
    <WhiteOnDarkGreyTooltip
      TransitionComponent={({ children }) => children}
      {...this.props}
      enterDelay={0}
      open={this.state.open}
      PopperProps={{
        placement: "bottom",
        disablePortal: !!this.props.disablePortal,
        modifiers: [
          {
            preventOverflow: {
              enabled: false,
              boundariesElement: "scrollParent"
            }
          }
        ]
      }}
    />
  );

  open = () => this.setState({ open: true });
  close = () => this.setState({ open: false });
}

Seeking to have black opaque background with white text in the tooltips, encountering some transparency issues in the specific usage mentioned above:

https://i.sstatic.net/NvnFv.png

Is there a way to remove any default opacity set by the Material UI library for this Component?

Answer №1

Even though this solution may be outdated, I came across the same issue and was looking for a resolution. I had also implemented disablePortal. However, to help future searchers, the fix is simply adding zIndex=100 in your code. In my case, using material-ui-popup-state, I included sx={{zindex:100}} within my <Popper /> component.

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

Is it possible for a table row's cell to determine the value of the cell in the row above it?

Let me illustrate my issue with an example. Consider the following table: <table> <tr> <th>First</th><th>Second</th><th>Third</th> </tr> <tr> <td>A</td><t ...

Updating a specific field within an array in a Meteor object using MongoDB

I have a document with game details and participants. Here is an example of the structure: { "gameName":"Shooter", "details":[ { "submitted":1415215991387, "author":"XYZ", "subPlayer":{ "members":{ ...

What is the best way to utilize two values in Vue.js 2?

When I attempt to structure my component in the following way: <script> export default { template: '\ <select class="form-control" v-on:change="search">\ <option v-for="option in option ...

CSS-enabled tabs built with React

Currently, I have a setup with 5 divs and 5 buttons where only one div is visible at a time when its corresponding button is clicked. However, I am looking for suggestions on how to improve the efficiency and readability of my code. If you have any best pr ...

Scrollable content below the div

I have encountered an issue where a div is positioned above another div, and when I scroll the upper div to the bottom, it ends up scrolling the entire body. To better illustrate this problem, I have created a demo on JSFiddle: http://jsfiddle.net/2Ydr4/ ...

Unable to display Material UI icon in React app browser

Here is a list of the dependencies that have been installed: "dependencies": { "@emotion/react": "^11.8.1", "@emotion/styled": "^11.8.1", "@mui/icons-material": "^5.4.2", ...

The initialization process of Vue.js router is compatible with router.map, but not with the Router constructor

I'm experiencing an issue in my app where routes work fine when I use router.map({}) with the vue-router, but they fail to work when I pass them directly in the constructor. Any insight into why this might be happening? // Routes that work: const rou ...

Displaying information based on selection in AngularJSIn this tutorial

I am a beginner in Angularjs and currently working on developing a website. One of the tasks I have is to create a combo box that, when an option is selected, calls a method to load values into a Scope variable and update it. Below is the code I have so fa ...

Transmit a parameter from a JavaScript code to a Python script

I am using a python script to execute queries in an Oracle Database by passing arguments. prov.py #!/usr/local/bin/python2.7 import sys import argparse import cx_Oracle import json import cgi import cgitb cgitb.enable() lst_proveedores=[{}] conn_str = & ...

Turn off all animations for a specific div or HTML page

Whenever I add an item to a div, there's this strange flashing animation happening. It's like a blink or flash that updates the div with new data. I'm not entirely sure if it's a jQuery animation or not. Is there any way to disable all ...

If the value of the "Global Region" field in the PDF form is not empty, then execute the following JavaScript code:

I need to restrict access to a PDF form when the "Global Region" field is filled out. Testing this code can be time-consuming, so I want to confirm that the syntax to check for a NOT NULL value in the Global Region Field is correct. if(this.getField("Gl ...

What is the best way to ensure my <h5> element fits perfectly inside its parent div vertically?

Currently facing an issue with finding a solution to my problem. The challenge involves having a header tag nested within multiple divs. Below is the structure: <div class="card"> <div class="layout-left"> <div class="card-header"> ...

Hide the button with jQuery Ajax if the variable is deemed acceptable upon submission

I need to figure out how to hide the submit button if the email entered is the same as the one in the database from action.php. Can anyone help me with integrating this functionality into my existing code? <form onsubmit="return submitdata();"> ...

Creating an asynchronous function in Node.js that returns a promise, but experiencing unexpected behavior when using console.log to display the result

Recently, I created a simple and compact API that determines the gender of a person. It functions by sending a get-request to a specific page which responds with a JSON object. This snippet illustrates how my module works: 'use strict'; const ht ...

What could be the reason for the malfunctioning of the header() function in PHP

Currently, I'm utilizing AJAX to facilitate user registration for a service. Here's the code snippet for the submit button: <input type="button" id="register" name="register" class="btn btn-success" onclick="registration();" value="Register"/ ...

AngularJS, sort through "afoo" excluding "foo"

I am attempting to implement a filter within an ng-repeat Main.HTML <table> <tr ng-repeat="param in MyParam | filter: UnrequestValue"> <td>{{param.Label}}</td> </tr> </table> Main.js MyParam: ...

What is preventing the terminal from recognizing that I have successfully updated to the newest version of tar?

Struggling to get the react app installed using this code: sudo npm i -g <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="107362757164753d62757173643d71606050213e253e22">[email protected]</a> Continuously facing t ...

What is the best way to find the index of the smallest value in an array using JavaScript?

I recently created this function that currently outputs -1. function sayHello() { let buildingLevelsArray = [11,10,10]; var smallestIndex = buildingLevelsArray.indexOf(Math.max(buildingLevelsArray)); console.log(smallestIndex); } sayHello() ...

Utilizing Modernizr for detecting support of background-clip:text functionality

Recently, I decided to utilize Modernizr in order to check for support of the css property background-clip: text. After some research, I came across this page:https://github.com/Modernizr/Modernizr/issues/199 I then added the following code to my website ...

Error: Module 'react' not found. Please make sure it is installed and correctly imported

Recently, I've been working on developing a React app using TypeScript. To kickstart the project, I used yarn create react-app (name) --use-pnp --typescript. However, I encountered an issue with the TS linter repeatedly showing the error: Cannot find ...