Interactivity

Cursor

Utilities for controlling the cursor style when hovering over an element.

Quick reference

Class
Properties
Preview 
cursor-autocursor: auto;Cursor - 图1
cursor-defaultcursor: default;Cursor - 图2
cursor-pointercursor: pointer;Cursor - 图3
cursor-waitcursor: wait;Cursor - 图4
cursor-textcursor: text;Cursor - 图5
cursor-movecursor: move;Cursor - 图6
cursor-helpcursor: help;Cursor - 图7
cursor-not-allowedcursor: not-allowed;Cursor - 图8
cursor-nonecursor: none;Cursor - 图9
cursor-context-menucursor: context-menu;Cursor - 图10
cursor-progresscursor: progress;Cursor - 图11
cursor-cellcursor: cell;Cursor - 图12
cursor-crosshaircursor: crosshair;Cursor - 图13
cursor-vertical-textcursor: vertical-text;Cursor - 图14
cursor-aliascursor: alias;Cursor - 图15
cursor-copycursor: copy;Cursor - 图16
cursor-no-dropcursor: no-drop;Cursor - 图17
cursor-grabcursor: grab;Cursor - 图18
cursor-grabbingcursor: grabbing;Cursor - 图19
cursor-all-scrollcursor: all-scroll;Cursor - 图20
cursor-col-resizecursor: col-resize;Cursor - 图21
cursor-row-resizecursor: row-resize;Cursor - 图22
cursor-n-resizecursor: n-resize;Cursor - 图23
cursor-e-resizecursor: e-resize;Cursor - 图24
cursor-s-resizecursor: s-resize;Cursor - 图25
cursor-w-resizecursor: w-resize;Cursor - 图26
cursor-ne-resizecursor: ne-resize;Cursor - 图27
cursor-nw-resizecursor: nw-resize;Cursor - 图28
cursor-se-resizecursor: se-resize;Cursor - 图29
cursor-sw-resizecursor: sw-resize;Cursor - 图30
cursor-ew-resizecursor: ew-resize;Cursor - 图31
cursor-ns-resizecursor: ns-resize;Cursor - 图32
cursor-nesw-resizecursor: nesw-resize;Cursor - 图33
cursor-nwse-resizecursor: nwse-resize;Cursor - 图34
cursor-zoom-incursor: zoom-in;Cursor - 图35
cursor-zoom-outcursor: zoom-out;Cursor - 图36

Show all classes

Basic Usage

Setting the cursor style

Use the cursor-{style} to control which cursor is displayed when hovering over an element.

Cursor - 图37

Hover over each button to see the cursor change

Cursor - 图38

  1. <button type="button" class="cursor-pointer ...">
  2. Submit
  3. </button>
  4. <button type="button" class="cursor-progress ...">
  5. Saving...
  6. </button>
  7. <button type="button" disabled class="cursor-not-allowed ...">
  8. Confirm
  9. </button>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use focus:cursor-auto to only apply the cursor-auto utility on focus.

  1. <div class="cursor-not-allowed focus:cursor-auto">
  2. <!-- ... -->
  3. </div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:cursor-auto to apply the cursor-auto utility at only medium screen sizes and above.

  1. <div class="cursor-not-allowed md:cursor-auto">
  2. <!-- ... -->
  3. </div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.

Using custom values

Customizing your theme

By default, Tailwind includes cursor utilities for many built in options. You can customize these values by editing theme.cursor or theme.extend.cursor in your tailwind.config.js file.

tailwind.config.js

  1. module.exports = { theme: { extend: { cursor: { 'fancy': 'url(hand.cur), pointer', } } }}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off cursor value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

  1. <div class="cursor-[url(hand.cur),_pointer]">
  2. <!-- ... -->
  3. </div>

Learn more about arbitrary value support in the arbitrary values documentation.