Customizing table row background color on hover or mouseover in Material UI datatable

Completely new to React and Material-UI.

I'm attempting to modify the color of table rows when hovering over them with the mouse.

I have tried various solutions from different posts but none have worked for me. (e.g. Root, cell, and tableRow)

The xx.js

export const xxTheme = createTheme({
    typography: {
        fontFamily: 'xxText',
        fontSize: 11,
    },

    tableRow: {
       "&$hover:hover": { backgroundColor: "blue"  }
    },

    tableCell: {
        "$hover:hover &": { color: "pink"
    }
},
hover: {},

overrides: {
    MuiTableCell: {
        root:{
            color: xxColors.grey2,
            '& .MuiCheckbox': { color: xxColors.grey2, },
            "&$hover:hover" : { backgroundColor: "blue" }
        },
        head: {...}

        tableRow: { "&$hover:hover": { backgroundColor: "cyan" }
        },
    },

In the xxTableBody.js

import {Table, TableContainer} from "@material-ui/core";
import {Checkbox, TableBody, TableCell, TableRow} from "@material-ui/core";
import {xxColors} from "../styles/xx";

<TableRow
    key={step.workStepId}
    ref={dragProvided.innerRef}
    selected={isItemSelected}
    aria-checked={isItemSelected}
    {...dragProvided.draggableProps}

    classes={{'hover':{color:'#7EA55FF'}}}
    style={{
          ...dragProvided.draggableProps.style,
          background: snapshot.isDragging   ? xxColors.blue1 : "none",
          }}
    >
   <TableCell key={'drag'} align={'left'}>
       <div {...dragProvided.dragHandleProps}>
           <ReorderIcon/>
       </div>
   </TableCell>

What needs to be addressed/fixed?

Thanks in advance

Answer №1

After eliminating the jss conditional 'snapshot.isDragging' and replacing it with standard CSS to set background = none, the issue was successfully resolved.

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

React-built NPM website fails to compile

After successfully running my website created with ReactJS on my local machine, I encountered an error when trying to build it using npm run build. The error message received was: > react-snap � pageerror at /personal-site/: SyntaxError: Unexpected ...

By default, the ItemActiveIndicator is not displayed in the Material 3 Bottom Navigation Bar on Android

Currently, I've added 'com.google.android.material:material:1.5.0' to Build.Gradle <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.andr ...

Can someone guide me on inserting checkboxes into the admin-on-rest datagrid component?

If you're struggling with the Datagrid component wrapping material-ui's Table component, the admin-on-rest documentation suggests passing material-ui Table options like checkboxes through headerOptions, rowOptions, bodyOptions, and options proper ...

Oops! There seems to be a server error with the PDFDownloadLink API. It appears that you are trying to use this web-specific API on Node, or perhaps your bundler is not loading react-pdf properly

I have developed a Report card generator in Next.js, and I am currently experimenting with the use of @react-pdf/renderer to generate PDFs before integrating it into my main project. However, I am encountering an error that I can't seem to resolve. S ...

How to solve a React Native CLI QuickStart error?

I'm currently working on my first React Native app, but I've encountered a problem: ✖ Issue with Bundler Installation error: It seems that the extensions for executable-hooks-1.6.1 are not built properly. Please try running "gem pristine execut ...

Store images securely in a private S3 bucket for access with Next.js

I am looking to access images from a private bucket instead of a public one. The code snippet below shows how I currently try to access the images, but I believe there must be a way to do so without making the entire bucket public. In my API file, I use AC ...

The react decorator for maintaining type safety fails to identify the appropriate ReturnType of the supplied function

I want to enhance the redux connect feature by using it as a decorator for a specific reducer/state. Although I know that redux connect can already be used as a decorator, I am curious about why my custom implementation does not work the way I expect. Her ...

I'm unable to import correctly using the --compiler option

Having an issue here. I'm trying to bring in the typescript compiler. I used this command: bit import bit.envs/compilers/typescript --compiler Unfortunately, it didn't work. This is the error message: bit import [ids...] import components in ...

Getting rid of the upper boundaries and outlines of the Bootstrap table

React code: <div style={{paddingLeft: '8px', paddingRight: '8px'}}> <div className="-subtitle"> <div className="pull-right" style={{marginBottom:'5px' ...

Exclusive to Safari: Codesandbox is experiencing difficulties retrieving data from the localhost server

Would you mind helping me out with this technical issue I'm facing? For the server/API, I am using this link. As for the mock website, it can be found at this URL. The problem is that, in my code, I'm using axios to fetch data from the locally h ...

Fluid UI Selection Grid Navigation

Currently utilizing Material-ui v1 beta, I am looking to implement a row of dropdown menus at the top of my web application for navigation purposes. While exploring the options available, I noticed the presence of the AppBar component with menu items, but ...

How can I make my webpage fill the entire width of an iPhone screen when in landscape mode using Angular or React?

While testing my website on my iPhone, I noticed a significant gap appearing on either side of the app in landscape view in Safari. Is there a solution to fix this issue? The problem occurs in both Angular and React applications, examples of which are disp ...

Retrieve events triggered by each element

Currently, my research centers around digital marketing and user experience. In order to gather the necessary data for this study, I must collect event logs from all components within a UI to create datasets on usability patterns. In a web interface, such ...

Styles for Material UI Autocomplete

I made custom changes to the MUI Autocomplete styles to suit my needs. Everything was functioning properly until I added disableClearable={true} as a prop. For some reason, the styles reverted back to their default values. <Autocomplete ...

Ways to resolve the error "Uncaught TypeError: data.map is not a function"

Currently developing an app using reactJS and encountering the following error in the console when using the map function: TypeError: data.map is not a function. Despite successful API data calling as confirmed by console.log, the error persists when tryin ...

I'm confused as to why the ID value is showing up as Undefined in the code snippet for React

Why do I keep getting 'undefined' when trying to console the id even though it should be in scope? function App() { let id; let [time, settime] = useState(''); function timechnage() { id = setInterval(() => { sett ...

Child component successfully received React test function

In my React app, I have a Parent component that contains a function to make an xhr call. This function is then passed down to a Child component, which collects user information and triggers the parent function upon clicking a submit button. Everything work ...

IE11 Error: Script1003 expected but not found

I'm in the process of adding IE11 support, but encountering the following errors: SCRIPT1003: Expected ':' File: vendor.bundle.js, Line: 8699, Column: 8 SCRIPT5009: 'webpackJsonp' is undefined File: app.bundle.js, Line: 1, Colum ...

State update is being delayed in the process of updating the state

Having trouble sending my form data to an API with this code: const handleSubmit = () => { setData({ ...data, apellidoParterno: inputs.apellidoParterno, apellidoMaterno: inputs.apellidoMaterno, ...

There was an issue with the NextJS axios request as it returned a status code

I'm currently in the process of developing an application with NextJS and Strapi In my project, I am fetching data from Strapi using Axios within NextJS Next: 14.0.4 Axios: ^1.6.5 Strapi: 4.17.1 Node: 18.17.0 Here is the code snippet: import axios f ...