# 状态圆点 · StatusDot

- 页面: https://jiguang132.com/zh/resources/astryx/docs/status-dot
- 资源: Astryx (https://jiguang132.com/zh/resources/astryx.md)
- 全部指南: https://jiguang132.com/zh/resources/astryx/docs.md

状态圆点用于反馈与状态场景。下面的官方示例展示原生用法与状态，属性名保持上游 API。

## 安装与前置条件

```bash
npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0
```

需要 React 19+，按顺序导入基础 CSS 和主题，并设置 Theme Provider。参见[开始使用](/resources/astryx/docs/getting-started)。

## 示例与使用方式

- **状态圆点 · 综合展示 / 状态 1**：首先体验这个示例，再查看代码理解组件的组合方式。
- **状态圆点 · 状态 2**：可交互查看这一用法的行为，复制代码时保留它实际使用的属性与导入。
- **状态圆点 · 状态 3**：可交互查看这一用法的行为，复制代码时保留它实际使用的属性与导入。
- **状态圆点 · 样式变化 / 状态 / 样式 4**：可交互查看这一用法的行为，复制代码时保留它实际使用的属性与导入。

## API 与上游详细参考

优先使用 0.7.1 官方中文说明；上游尚未提供中文的条目保留英文。属性名、类型及默认值保持原生 API，不把示例状态名称当成组件属性。

## Status Dot

A small colored dot that communicates status like online/offline presence or severity levels. Supports five semantic variants and an optional pulse animation. Always pair with a visible text label, as color alone should not carry meaning.

| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| variant * | 'success' \| 'warning' \| 'error' \| 'accent' \| 'neutral' |  | 语义颜色变体。 |
| label * | string |  | 通过 aria-label 暴露的无障碍标签。 |
| isPulsing | boolean | false | 启用脉冲动画；尊重 prefers-reduced-motion: reduce 设置。 |
| tooltip | string |  | Tooltip text shown on hover to explain the status meaning. |
| icon | ReactNode |  | 可选图标，居中渲染于圆点内，以 currentColor（变体的前景色）着色。为状态提供非颜色标记，请为每个状态使用不同图标。布尔值和空字符串会被忽略，因此 `cond && <Icon />` 是安全的。与 AvatarStatusDot 的契约一致。 |
| xstyle | StyleXStyles |  | 用于布局自定义的 StyleX 样式（外边距、定位、尺寸）。必须是 stylex.create() 的值，而非内联样式对象如 style={{}}。 |

### 使用建议

- Use StatusDot as a binary present/absent signal; avoid encoding many distinct states in a single dot, since color and size alone cannot reliably distinguish them.
- Always pair with a visible text label so status is not conveyed by color alone.
- Provide a descriptive `label` prop for screen reader accessibility.
- Pair the dot with an icon that carries the status as a distinct shape when it must stand on its own without adjacent text, so meaning survives without color.
- If you can't add a label or an icon, make sure the status is conveyed elsewhere accessibly (e.g. adjacent text, a table column, or a live region).
- 避免：Rely on color alone to communicate status; StatusDot is not fully accessible in isolation, so the builder must make the status distinguishable in context via a label, an icon, or an accessible alternative.
- 避免：Use the pulse animation for purely decorative purposes; reserve it for states that require immediate attention.

### 主题 API

```json
{
  "targets": [
    {
      "className": "astryx-status-dot",
      "visualProps": [
        "variant"
      ]
    }
  ]
}
```

### 组件结构

- **Dot**: Painted status dot that carries the selected semantic variant.
- **Status icon**: Optional caller-supplied icon rendered inside the dot.

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
