Card
由头部、主体与底部组成的 Shadcn 风格卡片容器组件。
用于组织关联内容的纯展示卡片容器,提供 Root、Header、Content 与 Footer 四个结构部件。本页示例采用 Shadcn Rhea 风格。
<wc-shadcn-card-root style-profile="rhea" class="w-full max-w-sm">
<wc-shadcn-card-header style-profile="rhea">
<h3 class="text-base font-medium">Deployment summary</h3>
<p class="text-sm text-muted-foreground">
Production release v2.4 is live across all regions.
</p>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<p class="text-sm">
All 12 edge workers passed health checks with 99.98% uptime
over the last 24 hours.
</p>
</wc-shadcn-card-content>
<wc-shadcn-card-footer style-profile="rhea">
<a
href="#card-contract"
class="text-sm font-medium underline underline-offset-4 hover:opacity-80"
>
View usage guide
</a>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>此组件由工作区源码提供。请在应用中安装同一工作区提交构建的 CLI、Shadcn 原型包与目标适配器,用该 CLI 初始化项目,再运行本地命令生成组件封装。
pnpm exec proto-ui add wc shadcn-card
npm exec -- proto-ui add wc shadcn-card
yarn exec proto-ui add wc shadcn-card
bun run proto-ui add wc shadcn-card
把 wc 替换为 react、vue 或 vue2,即可生成对应框架的本地组件封装。也可以直接从 @proto.ui/prototypes-shadcn/card 导入 ShadcnCardRoot、ShadcnCardHeader、ShadcnCardContent、ShadcnCardFooter(同时提供小写别名)。
用法
import { ShadcnCardRoot, ShadcnCardHeader, ShadcnCardContent, ShadcnCardFooter,} from '@proto.ui/prototypes-shadcn/card';<ShadcnCardRoot styleProfile="rhea"> <ShadcnCardHeader> <h3 className="text-base font-medium">Card Title</h3> <p className="text-sm text-muted-foreground">Card Description</p> </ShadcnCardHeader> <ShadcnCardContent> <p className="text-sm">Card Content</p> </ShadcnCardContent> <ShadcnCardFooter> <p className="text-sm">Card Footer</p> </ShadcnCardFooter></ShadcnCardRoot>结构组合方式:
ShadcnCardRoot├── ShadcnCardHeader├── ShadcnCardContent└── ShadcnCardFooter- 结构与排版:
Header、Content与Footer各自管理水平内边距与区域间距。标题和描述可直接使用原生标题/段落元素,或在嵌套 Text 时为标题使用size="base"、weight="medium"、tone="inherit",为辅助说明使用size="sm"、tone="muted"。 - 风格预设:未显式指定风格时,
Root会继承最近的 Style Scope;无外层作用域时默认使用new-york-v4(rounded-xl、边框、24px 间距与内边距、8px Header 间距)。在 Shadcn Rhea 风格下使用前景色 hairline ring、主题圆角上限 24px、20px 默认内边距与 16pxsm紧凑内边距;在 Shadcn Luma 风格下使用rounded-4xl大圆角、shadow-md柔阴影、ring-foreground/5(暗色ring-foreground/10)细腻轮廓与 24px 默认内边距(sm为 16px)。 - 纯展示语义:四个部件不附加交互角色、焦点或事件,卡片内部的链接、输入框与按钮保留各自的原生导航与交互行为。
结合 Header 操作按钮、Label / Input 表单项与全宽操作按钮构建经典登录卡片。
<wc-shadcn-card-root style-profile="rhea" class="w-full max-w-sm">
<wc-shadcn-card-header style-profile="rhea">
<div class="flex items-start justify-between gap-2">
<div class="grid gap-1">
<h3 class="text-base font-medium">Login to your account</h3>
<p class="text-sm text-muted-foreground">
Enter your email below to login to your account
</p>
</div>
<wc-shadcn-button
style-profile="rhea"
variant="link"
size="sm"
>
Sign Up
</wc-shadcn-button>
</div>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<div class="flex flex-col gap-5">
<div class="grid gap-2">
<label for="card-login-email" class="text-sm font-medium">
Email
</label>
<wc-shadcn-input-root
style-profile="rhea"
id="card-login-email"
placeholder="m@example.com"
></wc-shadcn-input-root>
</div>
<div class="grid gap-2">
<div class="flex items-center">
<label
for="card-login-password"
class="text-sm font-medium"
>
Password
</label>
<a
href="#card-contract"
class="ms-auto text-sm underline-offset-4 hover:underline"
>
Forgot your password?
</a>
</div>
<wc-shadcn-input-root
style-profile="rhea"
id="card-login-password"
placeholder="Enter your password"
></wc-shadcn-input-root>
</div>
</div>
</wc-shadcn-card-content>
<wc-shadcn-card-footer
style-profile="rhea"
class="flex-col gap-2"
>
<wc-shadcn-button style-profile="rhea" class="w-full">
Login
</wc-shadcn-button>
<wc-shadcn-button
style-profile="rhea"
variant="outline"
class="w-full"
>
Login with Google
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>在 Shadcn Rhea 或 Shadcn Luma 风格下为 Root 设置 size="sm",所有子区域自动切换到更紧凑的 16px 间距与内边距(默认尺寸下 Rhea 为 20px、Luma 为 24px)。
<wc-shadcn-card-root
style-profile="rhea"
size="sm"
class="w-full max-w-xs"
>
<wc-shadcn-card-header style-profile="rhea">
<h3 class="text-base font-medium">Scheduled reports</h3>
<p class="text-sm text-muted-foreground">
Weekly snapshots. No more manual exports.
</p>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<ul class="grid gap-2 py-1 text-sm">
<li>Choose a schedule (daily, or weekly).</li>
<li>Send to channels or specific teammates.</li>
<li>Include charts, tables, and key metrics.</li>
</ul>
</wc-shadcn-card-content>
<wc-shadcn-card-footer
style-profile="rhea"
class="flex-col gap-2"
>
<wc-shadcn-button style-profile="rhea" size="sm" class="w-full">
Set up scheduled reports
</wc-shadcn-button>
<wc-shadcn-button
style-profile="rhea"
variant="outline"
size="sm"
class="w-full"
>
See what's new
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>为 Header 与 Footer 设置 divider={true} 可展示带匹配内边距的区域分隔线,适合条款确认或长内容滚动面板。
<wc-shadcn-card-root style-profile="rhea" class="w-full max-w-sm">
<wc-shadcn-card-header style-profile="rhea" divider>
<h3 class="text-base font-medium">Terms of Service</h3>
<p class="text-sm text-muted-foreground">
Review the terms before accepting the agreement.
</p>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<div
class="max-h-40 space-y-3 overflow-y-auto text-sm leading-relaxed text-muted-foreground"
>
<p>
These terms govern your use of the workspace, including
access to shared documents and collaboration tools.
</p>
<p>
By continuing, you agree to keep your account credentials
secure.
</p>
</div>
</wc-shadcn-card-content>
<wc-shadcn-card-footer
style-profile="rhea"
divider
class="justify-end gap-2"
>
<wc-shadcn-button
style-profile="rhea"
variant="outline"
size="sm"
>
Decline
</wc-shadcn-button>
<wc-shadcn-button style-profile="rhea" size="sm">
Accept
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>在 Header 前放置封面图片并为 Root 添加 pt-0,借助 Shadcn Rhea 的圆角裁切即可让封面贴合顶部边界。
<wc-shadcn-card-root
style-profile="rhea"
class="w-full max-w-sm pt-0"
>
<img
src="/images/base-image/landscape.svg"
alt="Design systems meetup cover"
class="aspect-video w-full object-cover"
/>
<wc-shadcn-card-header style-profile="rhea">
<div class="flex items-center justify-between gap-2">
<h3 class="text-base font-medium">Design systems meetup</h3>
<span
class="rounded-full bg-secondary px-2.5 py-0.5 text-xs font-medium text-secondary-foreground"
>
Featured
</span>
</div>
<p class="text-sm text-muted-foreground">
A practical talk on component APIs, accessibility, and
shipping faster.
</p>
</wc-shadcn-card-header>
<wc-shadcn-card-footer style-profile="rhea">
<wc-shadcn-button style-profile="rhea" class="w-full">
View Event
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>密度与间距对比
Section titled “密度与间距对比”并排对比 size="default"(20px)与 size="sm"(16px)搭配分隔线时的整体节奏。
<div class="grid w-full max-w-2xl items-start gap-5 md:grid-cols-2">
<wc-shadcn-card-root style-profile="rhea" size="default">
<wc-shadcn-card-header style-profile="rhea" divider>
<h3 class="text-base font-medium">Default density</h3>
<p class="text-sm text-muted-foreground">
size="default" · 20px section inset & gap
</p>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<p class="text-sm">
Balanced rhythm for primary feature cards, forms, and
editorial summaries.
</p>
</wc-shadcn-card-content>
<wc-shadcn-card-footer style-profile="rhea" divider>
<wc-shadcn-button
style-profile="rhea"
variant="outline"
size="sm"
>
Open details
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>
<wc-shadcn-card-root style-profile="rhea" size="sm">
<wc-shadcn-card-header style-profile="rhea" divider>
<h3 class="text-base font-medium">Compact density</h3>
<p class="text-sm text-muted-foreground">
size="sm" · 16px section inset & gap
</p>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<p class="text-sm">
Tighter spacing for sidebar widgets, checklists, and
high-density dashboards.
</p>
</wc-shadcn-card-content>
<wc-shadcn-card-footer style-profile="rhea" divider>
<wc-shadcn-button
style-profile="rhea"
variant="outline"
size="sm"
>
Open details
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>
</div>从右到左(RTL)
Section titled “从右到左(RTL)”在容器上设置 dir="rtl" 并配合逻辑外边距类(如 ms-auto),卡片内排版与操作项可自然适配 RTL 书写方向。
<div dir="rtl" class="w-full max-w-sm">
<wc-shadcn-card-root style-profile="rhea" class="w-full">
<wc-shadcn-card-header style-profile="rhea">
<div class="flex items-start justify-between gap-2">
<div class="grid gap-1">
<h3 class="text-base font-medium">
تسجيل الدخول إلى حسابك
</h3>
<p class="text-sm text-muted-foreground">
أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك
</p>
</div>
<wc-shadcn-button
style-profile="rhea"
variant="link"
size="sm"
>
إنشاء حساب
</wc-shadcn-button>
</div>
</wc-shadcn-card-header>
<wc-shadcn-card-content style-profile="rhea">
<div class="grid gap-2">
<label for="rtl-email" class="text-sm font-medium">
البريد الإلكتروني
</label>
<wc-shadcn-input-root
style-profile="rhea"
id="rtl-email"
placeholder="m@example.com"
></wc-shadcn-input-root>
</div>
</wc-shadcn-card-content>
<wc-shadcn-card-footer
style-profile="rhea"
class="flex-col gap-2"
>
<wc-shadcn-button style-profile="rhea" class="w-full">
تسجيل الدخول
</wc-shadcn-button>
<wc-shadcn-button
style-profile="rhea"
variant="outline"
class="w-full"
>
تسجيل الدخول باستخدام Google
</wc-shadcn-button>
</wc-shadcn-card-footer>
</wc-shadcn-card-root>
</div>ShadcnCardRoot
Section titled “ShadcnCardRoot”卡片外层容器,同时作为子树的风格与密度作用域边界。
| 属性 | 类型 | 默认值 |
|---|---|---|
styleProfile | 'luma' 'rhea' 'new-york-v4' 'new-york' 'inherit' | 'inherit' → 最近 scope → 'new-york-v4' |
size | 'default' 'sm' | 'default' |
ShadcnCardHeader
Section titled “ShadcnCardHeader”卡片头部区域,默认使用两行自适应网格排版。
| 属性 | 类型 | 默认值 |
|---|---|---|
styleProfile | 'luma' 'rhea' 'new-york-v4' 'new-york' 'inherit' | 'inherit' |
divider | boolean | false |
ShadcnCardContent
Section titled “ShadcnCardContent”卡片主体内容区域,负责与头部/底部对齐的水平内边距。
| 属性 | 类型 | 默认值 |
|---|---|---|
styleProfile | 'luma' 'rhea' 'new-york-v4' 'new-york' 'inherit' | 'inherit' |
ShadcnCardFooter
Section titled “ShadcnCardFooter”卡片底部操作与元信息区域。
| 属性 | 类型 | 默认值 |
|---|---|---|
styleProfile | 'luma' 'rhea' 'new-york-v4' 'new-york' 'inherit' | 'inherit' |
divider | boolean | false |
四个部件均为纯展示插槽,不触发自定义事件,也不暴露交互方法。