1

Goal: I got certain svg circles in place, which are nodes from a D3 graph. I added a darkmode toggle and want to replace the default pointer cursor with an Xwing image. This should only be visible if I hover over an circle. All other elements are excluded.

Problem: I know how to change the cursor in general, like shown below, but I do not know how to change the cursor during an specific hover event. Any idea?

body {
    cursor: url("Xwing.png"), auto
}
2
  • what you mean by specific hover event? its a element based hover or js event Commented Mar 25, 2021 at 13:20
  • If I would hover over an circle element for example, I do not want the effect for all hover events. Like include circles and exclude buttons etc. Commented Mar 25, 2021 at 13:21

1 Answer 1

1

You could do with pseudo-class :not

If you need to show the cursor image to all use body or * instead of .circle

updated for toggle

.circle:not(.excludedClassName) {
  cursor: url("Xwing.png"), auto
}

/*disabled if dark class match*/
.dark .circle:not(.excludedClassName) { 
  cursor: pointer !important; /* it will overwrite the cursor*/
}
Sign up to request clarification or add additional context in comments.

2 Comments

Got you but how can I enable / disable this with with the help of a toggle? For example if darkmode disabled, cursor: pointer else if darkmode enabled cursor: url(Xwing.png), auto
you will control based on global parent component class. Check my updated answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.