Kombai Logo

Tailwind CSS Cursor

The cursor property controls how the mouse pointer appears when it hovers over an element. This property allows developers to define how users interact visually with elements in a user interface.

With Tailwind's utility classes, it becomes even simpler to control the cursor. In this guide, we will learn every step of working with cursor styling in Tailwind CSS.

ClassPropertiesExample
cursor-autocursor: auto;<div className="cursor-auto"></div>
cursor-defaultcursor: default;<div className="cursor-default"></div>
cursor-pointercursor: pointer;<div className="cursor-pointer"></div>
cursor-waitcursor: wait;<div className="cursor-wait"></div>
cursor-textcursor: text;<div className="cursor-text"></div>
cursor-movecursor: move;<div className="cursor-move"></div>
cursor-helpcursor: help;<div className="cursor-help"></div>
cursor-not-allowedcursor: not-allowed;<div className="cursor-not-allowed"></div>
cursor-nonecursor: none;<div className="cursor-none"></div>
cursor-context-menucursor: context-menu;<div className="cursor-context-menu"></div>
cursor-progresscursor: progress;<div className="cursor-progress"></div>
cursor-cellcursor: cell;<div className="cursor-cell"></div>
cursor-crosshaircursor: crosshair;<div className="cursor-crosshair"></div>
cursor-vertical-textcursor: vertical-text;<div className="cursor-vertical-text"></div>
cursor-aliascursor: alias;<div className="cursor-alias"></div>
cursor-copycursor: copy;<div className="cursor-copy"></div>
cursor-no-dropcursor: no-drop;<div className="cursor-no-drop"></div>
cursor-grabcursor: grab;<div className="cursor-grab"></div>
cursor-grabbingcursor: grabbing;<div className="cursor-grabbing"></div>
cursor-all-scrollcursor: all-scroll;<div className="cursor-all-scroll"></div>
cursor-col-resizecursor: col-resize;<div className="cursor-col-resize"></div>
cursor-row-resizecursor: row-resize;<div className="cursor-row-resize"></div>
cursor-n-resizecursor: n-resize;<div className="cursor-n-resize"></div>
cursor-e-resizecursor: e-resize;<div className="cursor-e-resize"></div>
cursor-s-resizecursor: s-resize;<div className="cursor-s-resize"></div>
cursor-w-resizecursor: w-resize;<div className="cursor-w-resize"></div>
cursor-ne-resizecursor: ne-resize;<div className="cursor-ne-resize"></div>
cursor-nw-resizecursor: nw-resize;<div className="cursor-nw-resize"></div>
cursor-se-resizecursor: se-resize;<div className="cursor-se-resize"></div>
cursor-sw-resizecursor: sw-resize;<div className="cursor-sw-resize"></div>
cursor-ew-resizecursor: ew-resize;<div className="cursor-ew-resize"></div>
cursor-ns-resizecursor: ns-resize;<div className="cursor-ns-resize"></div>
cursor-nesw-resizecursor: nesw-resize;<div className="cursor-nesw-resize"></div>
cursor-nwse-resizecursor: nwse-resize;<div className="cursor-nwse-resize"></div>
cursor-zoom-incursor: zoom-in;<div className="cursor-zoom-in"></div>
cursor-zoom-outcursor: zoom-out;<div className="cursor-zoom-out"></div>

Overview of Cursor

Adding the Cursor

To start, you can set the mouse pointer style directly on any HTML element by using Tailwind's cursor utilities. These classes correspond to CSS cursor functionalities like pointer, not-allowed, wait, and more. Below is how you can use the cursor property:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

States and Responsiveness

Hover and Focus States

Tailwind allows you to change cursor styles dynamically based on user interactions. In Tailwind CSS, this is made easy by using state-based modifiers like hover: or focus:. For example, below is a pointer cursor that becomes wait on focus:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Breakpoint Modifiers

You can also style cursors responsively based on screen size using Tailwind's breakpoint modifiers like sm, md, lg, etc. This enables you to adapt the user experience according to device dimensions fluidly.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Custom Cursor

While Tailwind comes with several predefined options, customizing cursor styles to match specific design needs or branding is incredibly easy. You can implement custom cursors by extending Tailwind's configuration or through arbitrary values.

Extending the Theme

Tailwind's configuration file (usually tailwind.config.js) allows us to extend default cursor options. This proves useful when you want to add unique styles for various use cases. After extending the configuration, use these utilities like any other Tailwind class:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Using Arbitrary Values

In scenarios where predefined values are insufficient and theme configuration is too much effort, arbitrary values come into play. Tailwind lets you define cursor values on-the-fly by wrapping the desired CSS property in square brackets.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Real World Examples

Interactive Product Cards Grid

This example shows a grid of product cards with different cursor styles based on product availability:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Custom File Upload Interface

This example demonstrates a file upload interface with different cursor states for drag and drop functionality.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Interactive Table with Sorting

This example shows a table with sortable columns and various cursor interactions:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

This example shows an image gallery with different cursor states for interactions:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Interactive Rating Component

This example demonstrates a rating component with different cursor interactions:

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Customization Examples

Custom Text Selection Cursor

Implement a text editor interface with a custom cursor for different text selection states.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

A photo gallery component that changes cursor to a magnifying glass on hover, perfect for image exploration interfaces.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Gradient Progress Cursor

A reading progress component that changes cursor based on scroll position, ideal for blog posts and articles.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Best Practices

Maintain Design Consistency

When building an interface with Tailwind CSS, ensuring consistent cursor styling is critical for a consistent user experience. Cursors should complement the interactive elements they represent, maintaining uniformity across buttons, links, and card elements. For instance, using cursor-pointer on all clickable items creates a predictable and seamless interaction model for users without confusion or unintended behaviors.

Ensure that all interactive elements, like buttons, links, and form inputs, have a cursor style that matches their expected behavior. For example, buttons use cursor-pointer, disabled buttons use cursor-not-allowed, and non-interactive containers default to cursor-auto. This simple yet effective approach enforces consistency and clarity for both designers and end-users.

Leverage Utility Combinations

Tailwind utilities thrive on being combined to achieve highly customized interfaces while keeping your codebase maintainable. For cursor-specific classes, pairing them with layout or spacing utilities is an effective way to meet both functional and aesthetic needs. For instance, you might group cursor-pointer with hover transitions (transition-colors and hover:bg-gray-100) to create interactive buttons.

Using consistent utility combinations also helps highlight semantic meaning. If you plan to draw attention to interactive elements that perform a destructive action, consider pairing cursor-pointer with a red color scheme and distinct hover states. This coordinated usage can guide users’ eyes toward interactive regions more naturally and emphasize key functionalities.

Accessibility Considerations

Enhance Readability and Navigability

Cursor styles may seem like a subtle aspect of your interface, but they can significantly impact how users read and navigate content. By providing clear visual cues, users immediately know where to click or tap, reducing guesswork and friction. This clarity helps everyone, including individuals who may struggle with complex layouts or smaller screens.

Readability is often influenced by spacing and contrast, but cursor indicators add another layer of feedback. For instance, ensuring that every interactive headline uses cursor-pointer alongside a distinct text color can help users visually parse content sections. This small but meaningful addition can improve how easily people navigate through dense or multi-layered interfaces.

Support Accessible Interactive Elements

Interactive components—from buttons to dropdown menus—rely on visual cues to guide user actions. Applying cursor utilities in a thoughtful way can make these elements more accessible. For example, a toggle switch that uses cursor-pointer for the actionable part and cursor-default for the label helps users understand exactly which region controls the action.

It’s also beneficial to consistently style focus states when dealing with interactive elements. While the cursor indicates hover or pointer presence, keyboard users rely on outlines. By providing both clear cursor and well-defined outlines, you meet a wide range of accessibility needs.