Tailwind CSS - Cursor
Tailwind CSS Cursor provides predefined classes that control the appearance of the cursor when hovering over an element.
Tailwind CSS Cursor Classes
Below is a list of Tailwind CSS Cursor classes that change the cursor style, such as pointers, text, and more.
| Class | CSS Properties |
|---|---|
| cursor-auto | cursor: auto; |
| cursor-default | cursor: default; |
| cursor-pointer | cursor: pointer; |
| cursor-wait | cursor: wait; |
| cursor-text | cursor: text; |
| cursor-move | cursor: move; |
| cursor-help | cursor: help; |
| cursor-not-allowed | cursor: not-allowed; |
| cursor-none | cursor: none; |
| cursor-context-menu | cursor: context-menu; |
| cursor-progress | cursor: progress; |
| cursor-cell | cursor: cell; |
| cursor-crosshair | cursor: crosshair; |
| cursor-vertical-text | cursor: vertical-text; |
| cursor-alias | cursor: alias; |
| cursor-copy | cursor: copy; |
| cursor-no-drop | cursor: no-drop; |
| cursor-grab | cursor: grab; |
| cursor-grabbing | cursor: grabbing; |
| cursor-all-scroll | cursor: all-scroll; |
| cursor-col-resize | cursor: col-resize; |
| cursor-row-resize | cursor: row-resize; |
| cursor-n-resize | cursor: n-resize; |
| cursor-e-resize | cursor: e-resize; |
| cursor-s-resize | cursor: s-resize; |
| cursor-w-resize | cursor: w-resize; |
| cursor-ne-resize | cursor: ne-resize; |
| cursor-nw-resize | cursor: nw-resize; |
| cursor-se-resize | cursor: se-resize; |
| cursor-sw-resize | cursor: sw-resize; |
| cursor-ew-resize | cursor: ew-resize; |
| cursor-ns-resize | cursor: ns-resize; |
| cursor-nesw-resize | cursor: nesw-resize; |
| cursor-nwse-resize | cursor: nwse-resize; |
| cursor-zoom-in | cursor: zoom-in; |
| cursor-zoom-out | cursor: zoom-out; |
Functionality of Tailwind CSS Cursor Classes
- cursor-auto: Sets the cursor to the default behavior of the browser.
- cursor-default: Displays the default arrow cursor.
- cursor-pointer: Changes the cursor to a hand icon to indicate clickable elements.
- cursor-wait: Displays a wait cursor, like a spinning wheel, to show that the user should wait.
- cursor-text: Shows a text selection cursor for selecting text.
- cursor-move: Displays a cursor with arrows for moving elements.
- cursor-help: Displays a help cursor, usually a question mark.
- cursor-not-allowed: Sets the cursor to indicate that the action is not allowed.
- cursor-none: Hides the cursor completely.
- cursor-context-menu: Displays a cursor to show that a context menu is available.
- cursor-progress: Displays a progress cursor, like a spinning circle, to indicate ongoing activity.
- cursor-cell: Sets the cursor to a cell icon.
- cursor-crosshair: Shows a crosshair cursor for tasks like drawing.
- cursor-vertical-text: Sets the cursor to indicate that vertical text can be selected.
- cursor-alias: Shows a cursor indicating that a link or shortcut is available.
- cursor-copy: Changes the cursor to a copy icon.
- cursor-no-drop: Displays a cursor showing that an element cannot be dropped.
- cursor-grab: Sets the cursor to indicate that the element can be grabbed.
- cursor-grabbing: Shows that an element is being dragged.
- cursor-all-scroll: Displays a cursor that allows scrolling in all directions.
- cursor-*-resize: Shows different resize cursors for various directions.
- cursor-zoom-in: Sets the cursor to indicate zooming in.
- cursor-zoom-out: Sets the cursor to indicate zooming out.
In cursor-*-resize, the '*' can be replaced with direction indicators such as n, e, s, w, ne, nw, se, sw, ew, ns, nesw, nwse, col, or row to specify the resize direction.
Tailwind CSS Cursor Class Examples
Below are examples of Tailwind CSS Cursor classes, which show how to apply different cursor styles to elements, such as pointers, text, and more, for improving user interactions.
Different Cursor Styles
This example shows how Tailwind CSS Cursor classes can be used to apply different cursor styles. Use the cursor-* utilities to adjust the cursor appearance according to your needs.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-3">
<h2 class="text-2xl font-bold mb-6">
Tailwind CSS Cursor
</h2>
<h3 class="font-bold underline mb-4">
Hover over the boxes to see different cursor styles.
</h3>
<div class="grid grid-cols-4 gap-4">
<div class="p-2 border border-teal-300 cursor-auto
bg-gray-100">
<p>auto</p>
</div>
<div class="p-2 border border-teal-300 cursor-pointer
bg-gray-100">
<p>pointer</p>
</div>
<div class="p-2 border border-teal-300 cursor-wait
bg-gray-100">
<p>wait</p>
</div>
<div class="p-2 border border-teal-300 cursor-text
bg-gray-100">
<p>text</p>
</div>
<div class="p-2 border border-teal-300 cursor-move
bg-gray-100">
<p>move</p>
</div>
<div class="p-2 border border-teal-300 cursor-help
bg-gray-100">
<p>help</p>
</div>
<div class="p-2 border border-teal-300 cursor-none
bg-gray-100">
<p>none</p>
</div>
<div class="p-2 border border-teal-300 cursor-crosshair
bg-gray-100">
<p>crosshair</p>
</div>
<div class="p-2 border border-teal-300 cursor-grab
bg-gray-100">
<p>grab</p>
</div>
<div class="p-2 border border-teal-300 cursor-grabbing
bg-gray-100">
<p>grabbing</p>
</div>
<div class="p-2 border border-teal-300 cursor-zoom-in
bg-gray-100">
<p>zoom-in</p>
</div>
<div class="p-2 border border-teal-300 cursor-zoom-out
bg-gray-100">
<p>zoom-out</p>
</div>
</div>
<p class="mt-6">Use <strong>cursor-*</strong>
classes to apply different cursor styles.
</p>
</body>
</html>
Resize Cursor Styles
This example shows how Tailwind CSS Cursor classes can be used to apply various resize cursor styles. Hover over the boxes to see the different resize cursors, and use cursor-*-resize classes to modify the cursor styles as needed.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-4">
<h2 class="text-2xl font-bold mb-6">
Tailwind CSS Cursor</h2>
<h3 class="font-bold underline mb-4">
Hover to see resize cursors:
</h3>
<div class="grid grid-cols-2 gap-4">
<div class="p-2 border border-pink-300 cursor-n-resize
flex justify-center">
<p>n-resize</p>
</div>
<div class="p-2 border border-pink-300 cursor-e-resize
flex justify-center">
<p>e-resize</p>
</div>
<div class="p-2 border border-teal-300 cursor-ne-resize
flex justify-center">
<p>ne-resize</p>
</div>
<div class="p-2 border border-teal-300 cursor-nw-resize
flex justify-center">
<p>nw-resize</p>
</div>
<div class="p-2 border border-rose-400 cursor-nesw-resize
flex justify-center">
<p>nesw-resize</p>
</div>
<div class="p-2 border border-rose-400 cursor-nwse-resize
flex justify-center">
<p>nwse-resize</p>
</div>
</div>
<p class="mt-4">Use <strong>cursor-*-resize</strong>
for resize styles.
</p>
</body>
</html>