用 `title` 指出哪个操作遇到了什么问题。需要更多上下文时，用 `detail` 说明用户可以怎样继续。可选的 `code` 使用等宽字体，方便核对或抄录。

```tsx
'use client'

import { useState } from 'react'
import { Button, ErrorCard } from '@ancrel/ui'
import '@ancrel/tokens/css'
import '@ancrel/ui/styles.css'

export default function App() {
  const [editing, setEditing] = useState(false)
  return editing ? <label>Document title <input defaultValue="Untitled" /></label> :
    <ErrorCard title="Document title already in use" tone="warning" code="E_DUPLICATE"
      detail="Choose another title to save a separate copy."
      actions={<Button onClick={() => setEditing(true)}>Rename document</Button>} />
}
```

Expected:

The warning explains the duplicate title and displays its code. Rename document opens a title field.

Build `@ancrel/tokens` and `@ancrel/ui` from the workspace root, then run `pnpm --filter @ancrel/example-error-card test`.

## 选择语气和操作

错误默认使用 `danger`，可继续处理的提醒可设置为 `warning`。卡片以 `alert` 区域播报内容，标题提供可访问名称。用文字说明严重程度，方便高对比度模式下的阅读。

通过 `actions` 传入带有明确标签的按钮或链接，点击后的行为由调用方实现。若用户只需阅读说明，可以省略操作区域。

| `Prop` | `Type` | `Required` | `Default` |
| - | - | - | - |
| `actions` | `ReactNode` | `false` | `—` |
| `className` | `string` | `false` | `—` |
| `code` | `string` | `false` | `—` |
| `detail` | `ReactNode` | `false` | `—` |
| `key` | `React.Key \| null \| undefined` | `false` | `—` |
| `ref` | `React.Ref<HTMLDivElement> \| undefined` | `false` | `—` |
| `title` | `ReactNode` | `true` | `—` |
| `tone` | `Tone` | `false` | `—` |

```ts
import * as React from 'react';
import type { ErrorCardProps } from './types.js';
export declare const ErrorCard: React.ForwardRefExoticComponent<ErrorCardProps & React.RefAttributes<HTMLDivElement>>;
```

`--ac-sys-status-warning-fg`

| `Context` | `--ac-sys-status-warning-fg` |
| - | - |
| `dark/compact` | `#edc678` |
| `dark/comfortable` | `#edc678` |
| `light/compact` | `#765400` |
| `light/comfortable` | `#765400` |
