Pointer Cursor in CSS

I am experiencing a strange issue. When I set the cursor attribute value directly as a string like

return (
  <Grid item>
    <Card 
      sx={{
        padding: "1rem",
        ":hover": {
          cursor: "pointer"
        }
      }}
    />
  </Grid>
)

it works as expected, however, if I create a constant with the value of "pointer" and pass it to the cursor attribute, it does not work.

const cursorPointer = "pointer";
return (
  <Grid item>
    <Card 
      sx={{
        padding: "1rem",
        ":hover": {
          cursor: { cursorPointer }
        }
      }}
    />
  </Grid>
)

I am using Material UI, Next.js, and TypeScript. Thank you.

Answer №1

The problem arises from not passing the intended value.

In the second scenario, it appears as follows:

{
 ":hover": {
  cursor: { cursorPointer: "pointer" }
 }
}

Instead of

{
 ":hover": {
  cursor: "pointer" 
 }
}

You have the option to use a variable with this format:

{
 ":hover": {
  cursor: cursorPointer 
 }
}

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

Preventing the "Block-scoped variable used before its declaration" error in an Angular/TypeScript tree structure with child/parent references

Imagine a scenario where we have a set of simple nodes/objects forming a tree structure, each with parent and children references. The challenge lies in the need to reference both the parent and children nodes independently from the tree itself. This means ...

Transitioning a JavaScriptIonicAngular 1 application to TypescriptIonic 2Angular 2 application

I am currently in the process of transitioning an App from JavaScript\Ionic\Angular1 to Typescript\Ionic2\Angular2 one file at a time. I have extensively researched various guides on migrating between these technologies, completed the A ...

Is it possible to edit multiple classes simultaneously in Bootstrap?

After creating a div with the class container and adding 50px padding to the top, I am now ready to add another container using Bootstrap's CSS. Do I need to create a new class like container-2 to edit the new container's style or are there multi ...

The useState variable remains unchanged even after being updated in useEffect due to the event

Currently, I am facing an issue in updating a stateful variable cameraPosition using TypeScript, React, and Babylon.js. Below is the code snippet: const camera = scene?.cameras[0]; const prevPositionRef = useRef<Nullable<Vector3>>(null); ...

Guide on transferring the td id value to a different page

document.getElementById('scdiv').innerHTML=Quantity <td id="scdiv"> </td> document.getElementById('quantitydiv').innerHTML=mrp <td id="quantitydiv"> </td> I am currently facing an issue where the code is being d ...

The saved editable input number is automatically pushed even without needing to click on save or cancel

I am working with a datatable, chart, and a label that shows the latest added value. The table and chart display time-series data for the last 30 minutes, including the timestamp and a random numerical value between 0 and 999. Every 10 seconds, a new data ...

The upper 50% is malfunctioning because the parent height is set to auto

Having a bit of trouble with vertically centering a child div within its parent. I've been using this mixin: @mixin vertical-align { position: relative; top: 50%; -webkit-transform: translateY(-50%); -ms-transform: translateY(-50%); ...

Creating personalized components - a step-by-step guide

I'm looking to customize the appearance of the snackbar background, buttons, and other elements in my Material UI project. As a newcomer to Material UI, I'm unsure if I'm taking the correct approach with this code snippet: const styles = { ...

table: column with percentage-based width AND a minimum width in pixels

Here is an example I'm working with: https://stackblitz.com/edit/js-ivvupc?file=index.html I need my table to be responsive, meaning it should become scrollable when the window size is reduced. The basic setup for this is already in place within the ...

Tips for choosing the initial paragraph within a div that has a designated class (CSS 2)

I have a <div> that contains multiple <p> elements, and I want to apply specific styling only to the first <p> within each <div> with a unique class called cnt. Please take note that this question may seem similar to others on SO, ...

I am faced with a challenge involving an asynchronous function and the best approach to executing it synchronously

I devised the following plan: // Primary Function to Follow // Capture necessary local data // Transform into required editable format // Iterate through user's local images // Append image names to converted d ...

Is there a way to line up these two tables or divs using a shared parent header div?

In the process of developing this webpage, I encountered a layout that resembles the following: https://i.sstatic.net/T8XHa.png Here is an approximation of the HTML structure: <div class="title"> <table> <tr> &l ...

Manipulating data with Angular 2 services: accessing and updating values

This code snippet is all about managing an array in Angular. The Injectable decorator is used to define a service called Svc with methods for setting and getting column definitions. import { Injectable } from '@angular/core'; @Injectable() ...

Can we show the dropdown with the active button?

Can someone assist me in transforming my sidebar buttons into dropdowns when viewed on a responsive layout? I'm looking for something similar to the sidebar (on the left) featured on this website: If possible, I would like the dropdown to only displa ...

Encountering a host configuration issue while trying to use next/image in a TypeScript environment

I understand that when using Next.js image components without TypeScript, the URL must be configured in next.config.js, but I'm unsure why this doesn't work with TypeScript. ..., is not set up under images in your next.config.js. Learn more her ...

"Ensuring a fixed table header (thead) with Bootstrap styling in AngularJS: A step-by-step guide

I'm struggling to make the header of my AngularJS webpage sticky using Bootstrap Styling. Despite trying multiple solutions, none seem to work correctly. Does anyone have a simple approach to fix this issue? Additionally, when I attempt to make the he ...

Tips on formatting dates in a Material UI text field

<TextField name="BalDueDate" format="MM/dd/yyyy" value={basicDetails.BalDueDate.slice(0,10)} onChange={event => { ...

Transferring information through parent-child components via onChange

I have a question regarding data binding. In my project, I have a parent component and two child components: Parent: directives: [firstChild,secondChild], template:' <first-child [showList]="showList" (emitShowList)="getShowList($event)"& ...

What is the best positioning option to choose: "Relative? Static, or something else?"

I decided not to use float for positioning my divs in CSS; instead, I used the position property with relative value. However, when viewing the site on different screen resolutions, all the divs end up getting jumbled. Can someone please explain what I m ...

The error message "Identifier 'title' is not defined. '{}' does not contain such a member angular 8" indicates that the title variable is not recognized or defined in the

Here is the code snippet of my component: import { Router, ActivatedRoute } from '@angular/router'; import { Component, OnInit } from '@angular/core'; import { CategoriesService } from 'src/app/categories.service'; import { P ...