1. 互動性
  2. cursor

互動性

cursor

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

類別樣式
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>

使用自訂值

使用 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() 函式。

響應式設計

cursor 工具類別 新增前綴 加上像md:這樣的斷點變體,以便僅在中等尺寸 螢幕尺寸及以上套用此工具類別

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

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

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