> 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.

# Card

数据展示`@rockshin/tao-ui`

[代码演示](#代码演示)[API](#api)

将相关内容、操作和标签视图组合在同一容器内。

组件采用 tao-ui 原生实现，公共 API 对齐 Ant Design 6.7.0。外观、主题 token 与 Semantic DOM 定制遵循 tao-ui，主题通过 `TaoProvider` 配置。

公共 Card API 遵循 6.7.0；样式使用 tao-ui token 与 Semantic DOM，标签页由 rc 底层引擎和 tao-ui 样式实现。

## 何时使用

用于呈现独立的信息记录，操作使用明确的链接或按钮。

## 代码演示


### 标题与额外操作
```tsx preview
import { useState } from "react";
import { Button, Card } from "@rockshin/tao-ui";

export default function Example() {
  const [saved, setSaved] = useState(false);
  return (
    <Card
      title="Workspace"
      extra={
        <Button size="small" onClick={() => setSaved(!saved)}>
          {saved ? "Saved" : "Save"}
        </Button>
      }
    >
      Keep related project information together.
    </Card>
  );
}
```

### 尺寸与变体
```tsx preview
import { Card } from "@rockshin/tao-ui";

export default function Example() {
  return (
    <div style={{ display: "flex", gap: 16, flexDirection: "column" }}>
      <Card size="small" title="Small card">
        Compact details.
      </Card>
      <Card title="Outlined card">Default surface.</Card>
      <div
        style={{ padding: 16, background: "var(--tao-color-fill-tertiary)" }}
      >
        <Card variant="borderless" title="Borderless">
          A surface inside a shaded region.
        </Card>
      </div>
    </div>
  );
}
```

### 封面、元信息与操作
```tsx preview
import { useState } from "react";
import { Avatar, Button, Card } from "@rockshin/tao-ui";

export default function Example() {
  const [saved, setSaved] = useState(false);
  const [message, setMessage] = useState("");
  return (
    <Card
      hoverable
      cover={
        <div
          style={{
            height: 110,
            background: "linear-gradient(120deg, #e6ded0, #91b2b1)",
          }}
        />
      }
      actions={[
        <Button key="save" size="small" onClick={() => setSaved(!saved)}>
          {saved ? "Saved" : "Save"}
        </Button>,
        <Button
          key="share"
          size="small"
          onClick={() => setMessage("Read-only access for all team members")}
        >
          Details
        </Button>,
      ]}
    >
      <Card.Meta
        avatar={<Avatar>AL</Avatar>}
        title="Design notes"
        description={message || "Updated today by Ada"}
      />
    </Card>
  );
}
```

### 受控标签页
```tsx preview
import { useState } from "react";
import { Card } from "@rockshin/tao-ui";

export default function Example() {
  const [tab, setTab] = useState("overview");
  return (
    <Card
      title="Project"
      tabList={[
        { key: "overview", label: "Overview" },
        { key: "activity", label: "Activity" },
      ]}
      activeTabKey={tab}
      onTabChange={setTab}
      tabProps={{ animated: true }}
    >
      <p>
        {tab === "overview"
          ? "Project summary and owners."
          : "The latest project activity."}
      </p>
    </Card>
  );
}
```

### 加载内容
```tsx preview
import { useState } from "react";
import { Button, Card } from "@rockshin/tao-ui";

export default function Example() {
  const [loading, setLoading] = useState(true);
  return (
    <div>
      <Button onClick={() => setLoading(!loading)} style={{ marginBottom: 16 }}>
        Toggle loading
      </Button>
      <Card title="Account" loading={loading}>
        <Card.Meta title="Ada Lovelace" description="Team workspace owner" />
      </Card>
    </div>
  );
}
```

### 网格与内部卡片
```tsx preview="iframe-follow"
import { Card } from "@rockshin/tao-ui";

export default function Example() {
  return (
    <div>
      <Card title="Regions">
        {["Asia", "Europe", "Americas"].map((region) => (
          <Card.Grid
            key={region}
            style={{ width: "33.333%", textAlign: "center" }}
          >
            {region}
          </Card.Grid>
        ))}
      </Card>
      <Card title="Account" style={{ marginTop: 16 }}>
        <Card type="inner" title="Billing">
          Monthly subscription.
        </Card>
      </Card>
    </div>
  );
}
```

### 语义样式与主题
```tsx preview
import { Card, TaoProvider } from "@rockshin/tao-ui";

export default function Example() {
  return (
    <TaoProvider
      theme={{ mode: "dark", token: { colorPrimary: "oklch(0.7 0.1 195)" } }}
    >
      <Card
        title="Local theme"
        styles={{
          header: { borderBottomColor: "var(--tao-color-primary)" },
          body: { padding: 20 },
        }}
      >
        This card inherits its local tokens and dark surface.
      </Card>
    </TaoProvider>
  );
}
```

## API


### [#](#card)Card



| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| bordered | @deprecated Use variant. | `boolean | undefined` | `-` |
| headStyle | @deprecated Use styles.header. | `CSSProperties | undefined` | `-` |
| bodyStyle | @deprecated Use styles.body. | `CSSProperties | undefined` | `-` |

