CSS Custom Cursor

Swaps the mouse pointer for custom SVG cursors inside an area, with a different one over links and a safe fallback.

  • cursor
  • svg cursor
  • pointer
  • crosshair
  • hotspot
  • portfolio
HTML
<div class="cursor-zone">
  <p>Move your mouse in here</p>
  <a href="#">and over this link</a>
</div>
CSS
.cursor-zone {
  display: grid;
  place-content: center;
  gap: 8px;
  width: 260px;
  height: 150px;
  border: 2px dashed #d6d3d1;
  border-radius: 16px;
  background: #fff;
  color: #57534e;
  font: 500 14px system-ui, sans-serif;
  text-align: center;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='12' fill='none' stroke='%231c1917' stroke-width='2'/%3E%3Ccircle cx='16' cy='16' r='3' fill='%23ea580c'/%3E%3C/svg%3E") 16 16, crosshair;
}

.cursor-zone p {
  margin: 0;
}

.cursor-zone a {
  color: #ea580c;
  font-weight: 700;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='14' fill='%23ea580c' fill-opacity='.85'/%3E%3Cpath d='M11 21 21 11M13 11h8v8' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 16 16, pointer;
}

.cursor-zone a:focus-visible {
  outline: 2px solid #ea580c;
  outline-offset: 3px;
  border-radius: 2px;
}

About this CSS Custom Cursor

This CSS Custom Cursor is 30 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses CSS Grid and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #d6d3d1
  • #fff
  • #57534e
  • #ea580c

How to use this custom cursor

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .cursor-zone class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback