Changing Cursor with CSS for better UX

Changing Cursor with CSS for better UX


2 min read

The cursor CSS property sets the type of mouse cursor, if any, to show when the mouse pointer is over an element.

There are some cases where the default cursor behaviour from the User Agent Stylesheet doesn’t cut it. In these cases, we ought to change the cursor to something that reflects the expected user interaction on that element.

Checkout all the cursors on codepen 🧑

Using a Custom Cursor ↓

The cursor property is specified as zero or more <url> values, separated by commas. The cursor property does accept SVG files in all its glory but not Gifs.

Yes, you can create your own custom cursor using any images like png, jpg, etc.

<div class="cursors">
  <button class="heart">Heart</button>
  <button class="earth">Earth</button>
  <button class="smile">Smile</button>
.cursors {
  display: flex;
  flex-wrap: wrap;
.heart {
  cursor: url(""), auto;
.earth {
  cursor: url(""), pointer;
.smile {
  cursor: url(""), pointer;



πŸ“ NOTE: The size of the images should not be greater than 32*32 DIP, else you will get the below warning and your image won't work.


I have used this website for resizing my images.

Reference 🧐

🌟 Twitter πŸ‘©πŸ»β€πŸ’» 🌟 Instagram

Did you find this article valuable?

Support Suprabha Supi by becoming a sponsor. Any amount is appreciated!