> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt.

# Result

反馈`@rockshin/tao-ui`

[API](#api)

展示操作结果，并提供继续或恢复操作。

## 何时使用

用于重要操作完成后或整页错误状态。短暂状态提示使用 message 或 notification。

## 示例


### 成功与下一步
操作按钮应说明下一步行为；此例仅更新本地状态。
```tsx preview="iframe-follow"
import { useState } from 'react';
import { Button, Result } from '@rockshin/tao-ui';

export default function Example() {
  const [opened, setOpened] = useState(false);
  return (
    <Result
      status="success"
      title="Workspace created"
      subTitle={
        opened
          ? 'The workspace overview is selected.'
          : 'Invite teammates or continue to your workspace.'
      }
      extra={<Button onClick={() => setOpened(true)}>Open workspace</Button>}
    />
  );
}
```

### 信息、警告与错误
根据操作结果选择状态，并通过文字说明问题。
```tsx preview
import { useState } from 'react';
import { Button, Result, Stack } from '@rockshin/tao-ui';
import type { ResultStatusType } from '@rockshin/tao-ui';

export default function Example() {
  const [status, setStatus] = useState<ResultStatusType>('info');
  return (
    <>
      <Stack direction="horizontal" gap="sm" style={{ flexWrap: 'wrap' }}>
        {(['info', 'warning', 'error'] as const).map((value) => (
          <Button
            key={value}
            variant="secondary"
            onClick={() => setStatus(value)}
          >
            {value}
          </Button>
        ))}
      </Stack>
      <Result
        status={status}
        title={
          status === 'error'
            ? 'Import failed'
            : status === 'warning'
              ? 'Review required'
              : 'Import is queued'
        }
        subTitle="Open the import details to see the next step."
      />
    </>
  );
}
```

### HTTP 错误页面
403、404、500 提供独立插画；标题和恢复建议由应用提供。
```tsx preview
import { useState } from 'react';
import { Button, Result, Stack } from '@rockshin/tao-ui';

export default function Example() {
  const [status, setStatus] = useState<403 | 404 | 500>(404);
  const titles = {
    403: 'Access required',
    404: 'Page not found',
    500: 'Unable to load this page',
  };
  return (
    <>
      <Stack direction="horizontal" gap="sm">
        {([403, 404, 500] as const).map((value) => (
          <Button
            key={value}
            variant="secondary"
            onClick={() => setStatus(value)}
          >
            {value}
          </Button>
        ))}
      </Stack>
      <Result
        status={status}
        title={titles[status]}
        subTitle="Check your access or return to your workspace."
      />
    </>
  );
}
```

### 错误详情
children 用于展示可处理的详细原因，主标题保持简短。
```tsx preview
import { Result } from '@rockshin/tao-ui';

export default function Example() {
  return (
    <Result
      status="error"
      title="Two records need attention"
      subTitle="Fix the highlighted fields before retrying."
    >
      <ul>
        <li>Row 12: enter a valid email address.</li>
        <li>Row 28: choose a workspace owner.</li>
      </ul>
    </Result>
  );
}
```

### 自定义图标与语义样式
使用 Semantic DOM 分别定制图标、标题和正文。
```tsx preview
import { Result } from '@rockshin/tao-ui';

export default function Example() {
  return (
    <Result
      icon={
        <svg viewBox="0 0 48 48" fill="none" aria-hidden="true">
          <path
            d="M8 12h32v24H8zM8 12l16 13 16-13"
            stroke="currentColor"
            strokeWidth="2"
            strokeLinejoin="round"
          />
        </svg>
      }
      title="Invitation prepared"
      subTitle="Review the recipient before sending."
      styles={{
        icon: { color: 'var(--tao-primary)' },
        title: { fontSize: 20 },
        root: { padding: 20 },
      }}
    />
  );
}
```

## API


### [#](#result)Result



| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |

