Interactivity

cursor

用於控制滑鼠懸停在元素上時的游標樣式的通用類別。

ClassStyles
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;

範例(Examples)

基本範例(Basic example)

使用 cursor-pointercursor-grab 等通用類別來控制滑鼠懸停在元素上時顯示哪種游標:

將滑鼠懸停在每個按鈕上以查看游標變化

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

使用自訂值(Using a custom value)

使用 cursor-[<value>] 語法,根據完全自訂的值來設定 cursor

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

對於 CSS 變數,你也可以使用 cursor-(<custom-property>) 語法:

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

這只是 cursor-[var(<custom-property>)] 的簡寫形式,會自動為你加上 var() 函式。

響應式設計(Responsive design)

cursor 通用類別前面加上像 md: 這樣的中斷點變體,讓該通用類別只在中型螢幕尺寸及以上時套用:

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

變體文件中了解更多關於使用變體的資訊。

Copyright © 2026 Tailwind Labs Inc.·商標政策(Brand)