logo
导航

ProductCard

基础产品卡片

最基本的产品信息展示卡片

示例产品 product image

示例产品

这是一款功能强大的示例产品,为用户提供优质体验。

<ProductCard
name="示例产品"
image="/images/products/example-product.jpg"
description="这是一款功能强大的示例产品,为用户提供优质体验。"
productUrl="https://example.com/product"
/>

带App Store链接的产品卡片

同时提供产品官网和App Store下载链接

移动应用示例 product image

移动应用示例

一款优秀的移动应用,让您随时随地享受便捷服务。

<ProductCard
name="移动应用示例"
image={getExampleImage({ width: 300, height: 200 })}
description="一款优秀的移动应用,让您随时随地享受便捷服务。"
productUrl="https://example.com/app"
appStoreUrl="https://apps.apple.com/app/example"
/>

带GitHub链接的产品卡片

对于开源产品,可以同时提供官网、GitHub和App Store链接

开源项目示例 product image

开源项目示例

一个优秀的开源项目,欢迎参与贡献。

<ProductCard
name="开源项目示例"
image={getExampleImage({ width: 300, height: 200 })}
description="一个优秀的开源项目,欢迎参与贡献。"
productUrl="https://example.com/opensource"
githubUrl="https://github.com/example/repo"
appStoreUrl="https://apps.apple.com/app/opensource"
/>

自定义按钮文本

通过 primaryButtonTextsecondaryButtonTextgithubButtonText 属性自定义按钮文本

自定义按钮示例 product image

自定义按钮示例

此产品支持自定义按钮文本,提供更灵活的展示方式。

<ProductCard
name="自定义按钮示例"
image={getExampleImage({ width: 300, height: 200 })}
description="此产品支持自定义按钮文本,提供更灵活的展示方式。"
productUrl="https://example.com/custom"
appStoreUrl="https://apps.apple.com/app/custom"
githubUrl="https://github.com/example/custom"
primaryButtonText="查看详情"
secondaryButtonText="立即下载"
githubButtonText="查看源码"
/>

垂直按钮布局

通过 buttonLayout="column" 属性设置按钮垂直排列

垂直按钮示例 product image

垂直按钮示例

使用垂直按钮布局,适合需要强调各个操作的场景。

<ProductCard
name="垂直按钮示例"
image={getExampleImage({ width: 300, height: 200 })}
description="使用垂直按钮布局,适合需要强调各个操作的场景。"
productUrl="https://example.com/vertical"
appStoreUrl="https://apps.apple.com/app/vertical"
githubUrl="https://github.com/example/vertical"
buttonLayout="column"
/>

等高卡片布局

在网格或列表中展示多个产品卡片时,可能会因为内容长度不同导致卡片高度不一致,影响整体美观。 通过设置 equalHeight 属性,可以确保所有卡片高度一致,实现整齐的布局效果。

产品一 product image

产品一

这是一段很短的产品描述。

产品二 product image

产品二

这是一段较长的产品描述,包含更多详细信息,可能会导致卡片高度增加。使用equalHeight属性可以确保所有卡片高度一致。

<div class="cosy:grid cosy:grid-cols-2 cosy:gap-4">
<ProductCard
  equalHeight
  size="md"
  name="产品一"
  image={getExampleImage({ width: 300, height: 200 })}
  description="这是一段很短的产品描述。"
  productUrl="https://example.com/product1"
/>
<ProductCard
  equalHeight
  size="md"
  name="产品二"
  image={getExampleImage({ width: 300, height: 200 })}
  description="这是一段较长的产品描述,包含更多详细信息,可能会导致卡片高度增加。使用equalHeight属性可以确保所有卡片高度一致。"
  productUrl="https://example.com/product2"
  appStoreUrl="https://apps.apple.com/app/product2"
/>
</div>

控制描述文本行数

通过 descriptionLines 属性可以控制描述文本的最大显示行数,超出部分会被截断并显示省略号。 这有助于保持布局的一致性,防止过长的描述文本破坏卡片设计。

默认行数限制 product image

默认行数限制

默认情况下,描述文本会根据卡片尺寸自动限制行数。例如中等尺寸(md)卡片默认显示3行文本。这段文本很长,但只会显示前几行,其余部分会被截断。

自定义行数限制 product image

自定义行数限制

通过设置descriptionLines=2,可以将描述文本限制为最多显示2行。这段文本很长,但只会显示2行,其余部分会被截断。

<div class="cosy:grid cosy:grid-cols-2 cosy:gap-4">
<ProductCard
  size="md"
  name="默认行数限制"
  image={getExampleImage({ width: 300, height: 200 })}
  description="默认情况下,描述文本会根据卡片尺寸自动限制行数。例如中等尺寸(md)卡片默认显示3行文本。这段文本很长,但只会显示前几行,其余部分会被截断。"
  productUrl="https://example.com/product3"
/>
<ProductCard
  size="md"
  descriptionLines={2}
  name="自定义行数限制"
  image={getExampleImage({ width: 300, height: 200 })}
  description="通过设置descriptionLines=2,可以将描述文本限制为最多显示2行。这段文本很长,但只会显示2行,其余部分会被截断。"
  productUrl="https://example.com/product4"
/>
</div>

完整的网格布局示例

结合 equalHeightdescriptionLines 属性,可以创建一个整齐、一致的产品网格布局。

产品A product image

产品A

简短的产品描述文本。

产品B product image

产品B

中等长度的产品描述文本,提供一些基本信息。

产品C product image

产品C

较长的产品描述文本,包含更多详细信息,但会被限制为2行显示。

<div class="cosy:grid cosy:grid-cols-3 cosy:gap-4">
<ProductCard
  equalHeight
  size="sm"
  descriptionLines={2}
  name="产品A"
  image={getExampleImage({ width: 300, height: 200 })}
  description="简短的产品描述文本。"
  productUrl="https://example.com/productA"
/>
<ProductCard
  equalHeight
  size="sm"
  descriptionLines={2}
  name="产品B"
  image={getExampleImage({ width: 300, height: 200 })}
  description="中等长度的产品描述文本,提供一些基本信息。"
  productUrl="https://example.com/productB"
  appStoreUrl="https://apps.apple.com/app/productB"
/>
<ProductCard
  equalHeight
  size="sm"
  descriptionLines={2}
  name="产品C"
  image={getExampleImage({ width: 300, height: 200 })}
  description="较长的产品描述文本,包含更多详细信息,但会被限制为2行显示。"
  productUrl="https://example.com/productC"
  githubUrl="https://github.com/example/productC"
/>
</div>

不同尺寸的产品卡片

ProductCard 组件提供了五种预设尺寸:xs、sm、md、lg 和 xl,以适应不同的场景需求。

超小尺寸 (xs)

适合密集布局或侧边栏展示

超小尺寸产品 product image

超小尺寸产品

小巧精致的产品卡片,节省空间。

<ProductCard
size="xs"
name="超小尺寸产品"
image={getExampleImage({ width: 150, height: 100 })}
description="小巧精致的产品卡片,节省空间。"
productUrl="https://example.com/xs"
/>

小尺寸 (sm)

适合列表页面或网格布局

小尺寸产品 product image

小尺寸产品

紧凑型产品卡片,适合在列表中展示。

<ProductCard
size="sm"
name="小尺寸产品"
image={getExampleImage({ width: 150, height: 100 })}
description="紧凑型产品卡片,适合在列表中展示。"
productUrl="https://example.com/sm"
/>

中等尺寸 (md) - 默认

适合一般产品展示页面

中等尺寸产品 product image

中等尺寸产品

标准产品卡片,平衡信息展示和空间占用。

<ProductCard
size="md"
name="中等尺寸产品"
image="/images/products/example-md.jpg"
description="标准产品卡片,平衡信息展示和空间占用。"
productUrl="https://example.com/md"
/>

大尺寸 (lg)

适合突出显示重要产品

大尺寸产品 product image

大尺寸产品

大尺寸产品卡片,提供更多细节和视觉吸引力,适合突出展示重要产品。

<ProductCard
size="lg"
name="大尺寸产品"
image={getExampleImage({ width: 380, height: 253 })}
description="大尺寸产品卡片,提供更多细节和视觉吸引力,适合突出展示重要产品。"
productUrl="https://example.com/lg"
/>

超大尺寸 (xl)

适合特色产品或首页展示

超大尺寸产品 product image

超大尺寸产品

超大尺寸产品卡片,提供最佳视觉体验和完整信息展示,适合特色产品或首页展示。

<ProductCard
size="xl"
name="超大尺寸产品"
image={getExampleImage({ width: 480, height: 320 })}
description="超大尺寸产品卡片,提供最佳视觉体验和完整信息展示,适合特色产品或首页展示。"
productUrl="https://example.com/xl"
appStoreUrl="https://apps.apple.com/app/example-xl"
/>