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-context-menucursor: context-menu;Cursor - 图9
cursor-progresscursor: progress;Cursor - 图10
cursor-cellcursor: cell;Cursor - 图11
cursor-crosshaircursor: crosshair;Cursor - 图12
cursor-vertical-textcursor: vertical-text;Cursor - 图13
cursor-aliascursor: alias;Cursor - 图14
cursor-copycursor: copy;Cursor - 图15
cursor-no-dropcursor: no-drop;Cursor - 图16
cursor-grabcursor: grab;Cursor - 图17
cursor-grabbingcursor: grabbing;Cursor - 图18
cursor-all-scrollcursor: all-scroll;Cursor - 图19
cursor-col-resizecursor: col-resize;Cursor - 图20
cursor-row-resizecursor: row-resize;Cursor - 图21
cursor-n-resizecursor: n-resize;Cursor - 图22
cursor-e-resizecursor: e-resize;Cursor - 图23
cursor-s-resizecursor: s-resize;Cursor - 图24
cursor-w-resizecursor: w-resize;Cursor - 图25
cursor-ne-resizecursor: ne-resize;Cursor - 图26
cursor-nw-resizecursor: nw-resize;Cursor - 图27
cursor-se-resizecursor: se-resize;Cursor - 图28
cursor-sw-resizecursor: sw-resize;Cursor - 图29
cursor-ew-resizecursor: ew-resize;Cursor - 图30
cursor-ns-resizecursor: ns-resize;Cursor - 图31
cursor-nesw-resizecursor: nesw-resize;Cursor - 图32
cursor-nwse-resizecursor: nwse-resize;Cursor - 图33
cursor-zoom-incursor: zoom-in;Cursor - 图34
cursor-zoom-outcursor: zoom-out;Cursor - 图35

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 - 图36

Hover over each button to see the cursor change

Cursor - 图37

  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 = {
  2. theme: {
  3. extend: {
  4. cursor: {
  5. 'fancy': 'url(hand.cur), pointer',
  6. }
  7. }
  8. }
  9. }

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.