1. 交互性
  2. 光标

交互性

光标

用于控制鼠标悬停在元素上时鼠标光标样式的实用工具。

样式
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-pointercursor-grab 等实用工具来控制悬停在元素上时显示的光标。

悬停在每个按钮上以查看光标变化

<button class="cursor-pointer ...">Submit</button><button class="cursor-progress ...">Saving...</button><button class="cursor-not-allowed ..." disabled>Confirm</button>

使用自定义值

使用 光标-[<值>] 语法 设置光标基于完全自定义的值

<button class="cursor-[url(hand.cur),_pointer] ...">  <!-- ... --></button>

对于 CSS 变量,您也可以使用 光标-(<自定义属性>) 语法

<button class="cursor-(--my-cursor) ...">  <!-- ... --></button>

这只是 光标-[var(<自定义属性>)] 的简写,它会自动为您添加 var() 函数。

响应式设计

使用像 md: 这样的断点变体作为前缀一个 cursor 实用工具 仅在中等 屏幕尺寸及以上时应用该实用工具

<button class="cursor-not-allowed md:cursor-auto ...">  <!-- ... --></button>

变体文档中了解有关使用变体的更多信息。

Copyright © 2025 Tailwind Labs Inc.·商标政策