> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# cursor

APISummary
## 介绍

CSS 属性 `cursor` 用于控制鼠标悬停在元素上时显示的指针样式。

## 使用示例

**下面是一个示例: desktop**

**Entry:** `src/cursor`
**Bundle:** `dist/cursor.lynx.bundle` | Web: `dist/cursor.web.bundle`

```tsx
import { useResponsiveScale } from "../useResponsiveScale";
import "./App.css";

const cursorPresets = [
  "default",
  "pointer",
  "text",
  "grab",
  "grabbing",
  "not-allowed",
] as const;

export function App() {
  const { handleLayoutChange, scale } = useResponsiveScale({
    baseWidth: 640,
    baseHeight: 420,
    minScale: 0.58,
  });
  const pageStyle = {
    padding: `${32 * scale}px`,
  };
  const panelStyle = {
    padding: `${28 * scale}px`,
    gap: `${18 * scale}px`,
    borderRadius: `${28 * scale}px`,
  };
  const eyebrowStyle = {
    fontSize: `${14 * scale}px`,
    letterSpacing: `${scale}px`,
  };
  const titleStyle = {
    fontSize: `${34 * scale}px`,
  };
  const subtitleStyle = {
    fontSize: `${16 * scale}px`,
  };
  const buttonsStyle = {
    gap: `${12 * scale}px`,
  };
  const buttonStyle = {
    minWidth: `${96 * scale}px`,
    padding: `${14 * scale}px ${16 * scale}px`,
    borderRadius: `${16 * scale}px`,
  };
  const buttonTextStyle = {
    fontSize: `${16 * scale}px`,
  };

  return (
    <view className="Page" style={pageStyle} bindlayoutchange={handleLayoutChange}>
      <view className="Panel" style={panelStyle}>
        <text className="Eyebrow" style={eyebrowStyle}>CSS cursor</text>
        <text className="Title" style={titleStyle}>Hover the buttons to preview cursor keywords.</text>
        <text className="Subtitle" style={subtitleStyle}>Each button applies its own cursor value.</text>

        <view className="Buttons" style={buttonsStyle}>
          {cursorPresets.map(cursor => (
            <view
              key={cursor}
              className="Button"
              style={{ ...buttonStyle, cursor }}
            >
              <text className="ButtonText" style={buttonTextStyle}>{cursor}</text>
            </view>
          ))}
        </view>
      </view>
    </view>
  );
}

```

v0.3.1



## 语法

```css
cursor: pointer;
```

### 取值

Lynx 目前只支持 keyword 关键字取值，例如 `pointer`、`text`、`grab` 等标准光标关键字。

## Lynx 小程序语法

你可以像使用其他 CSS 属性一样声明 `cursor`。

```html
<view class="clickable">
  <text>Hover me</text>
</view>
```

```css
.clickable {
  cursor: pointer;
}
```

如果你的编译链路没有按预期让 `cursor` 生效，优先改用样式表选择器或 class 声明。

## React 语法

```tsx
<view style={{ cursor: 'pointer' }}>
  <text>Hover me</text>
</view>
```

## 形式定义

| 初始值 | auto |
| 适用元素 | 所有元素 |
| 是否支持继承 | yes |
| 是否支持动画 | no |


## 形式语法

```css
cursor: <cursor-keyword>;
```

## 与 Web 的区别

- 目前只支持 keyword 关键字取值。
- 暂不支持 URL 光标、本地图片光标，以及自定义 hotspot 位置。

## 注意事项

- 如果希望 `cursor` 在 Lynx 中参与继承，需要先在前端配置中启用 CSS inheritance。
- 你也可以显式将 `cursor` 加入 `customCSSInheritanceList`。
- 更多说明可参考 [`enableCSSInheritance`](/next/zh/api/packages/react-rsbuild-plugin.md#enablecssinheritance) 和 [`customCSSInheritanceList`](/next/zh/api/packages/react-rsbuild-plugin.md#customcssinheritancelist)。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.cursor`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json) · [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/cursor)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| cursor | No | No | No | Partial (3.7) | Partial (3.7) | Yes |
| default | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| none | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| context-menu | No | No | No | Yes (3.7) | No | Yes |
| help | No | No | No | No | Yes (3.7) | Yes |
| pointer | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| progress | No | No | No | No | Yes (3.7) | Yes |
| wait | No | No | No | No | Yes (3.7) | Yes |
| crosshair | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| text | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| vertical-text | No | No | No | Yes (3.7) | No | Yes |
| alias | No | No | No | Yes (3.7) | No | Yes |
| copy | No | No | No | Yes (3.7) | No | Yes |
| move | No | No | No | No | Yes (3.7) | Yes |
| no-drop | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| not-allowed | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| grab | No | No | No | Yes (3.7) | No | Yes |
| grabbing | No | No | No | Yes (3.7) | No | Yes |
| col-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| row-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| n-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| e-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| s-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| w-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| ne-resize | No | No | No | No | Yes (3.7) | Yes |
| nw-resize | No | No | No | No | Yes (3.7) | Yes |
| se-resize | No | No | No | No | Yes (3.7) | Yes |
| sw-resize | No | No | No | No | Yes (3.7) | Yes |
| ew-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| ns-resize | No | No | No | Yes (3.7) | Yes (3.7) | Yes |
| nesw-resize | No | No | No | No | Yes (3.7) | Yes |
| nwse-resize | No | No | No | No | Yes (3.7) | Yes |

**`cursor`**

The cursor CSS property controls the mouse pointer displayed when the pointer hovers over an element.

**Specifications:**

- **macOS — From 3.7:** Partial support; Keyword values only. URL-based cursors, local image cursors, and custom hotspot positions are not supported.
- **Windows — From 3.7:** Partial support; Keyword values only. URL-based cursors, local image cursors, and custom hotspot positions are not supported.

**`default`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`none`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`context-menu`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`help`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`pointer`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`progress`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`wait`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`crosshair`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`text`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`vertical-text`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`alias`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`copy`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`move`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`no-drop`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`not-allowed`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`grab`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`grabbing`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`col-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`row-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`n-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`e-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`s-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`w-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`ne-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`nw-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`se-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`sw-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`ew-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`ns-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`nesw-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

**`nwse-resize`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/191-cursor.json)

