tailwind-ecommerce
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEcommerce UI with Tailwind CSS
基于Tailwind CSS的电商UI
Patterns for product display, cart, checkout, orders, and store navigation.
包含商品展示、购物车、结账、订单及店铺导航的各类设计模式。
1. Product Display Patterns
1. 商品展示设计模式
Card Variants
卡片变体
| Variant | Key Classes | Use Case |
|---|---|---|
| Simple grid card | | Category pages, minimal listings |
| Card with details | | Product listings, search results |
| Horizontal card | | Cart items, wishlists, comparisons |
| Quick view overlay | | Browse-and-add flows |
| Featured card | | Homepage hero products |
| 变体类型 | 核心类名 | 使用场景 |
|---|---|---|
| 简约网格卡片 | | 分类页面、极简商品列表 |
| 带详情卡片 | | 商品列表页、搜索结果页 |
| 横向卡片 | | 购物车商品、心愿单、商品对比 |
| 快速查看浮层 | | 浏览加购流程 |
| 精选卡片 | | 首页核心推荐商品 |
Image Handling
图片处理
| Concern | Pattern | Classes |
|---|---|---|
| Aspect ratio | Fixed ratio container | |
| Fill behavior | Cover without distortion | |
| Responsive sizing | Fluid width, fixed aspect | |
| Placeholder | Background color fallback | |
| Hover zoom | Scale on group hover | |
| Lazy loading | Native attribute | |
| 关注点 | 实现模式 | 类名 |
|---|---|---|
| 宽高比 | 固定比例容器 | |
| 填充方式 | 无变形覆盖 | |
| 响应式尺寸 | 流体宽度+固定比例 | 容器用 |
| 占位符 | 背景色兜底 | 容器用 |
| 悬停缩放 | 分组悬停时缩放 | |
| 懒加载 | 原生属性 | |
Price Display
价格展示
| Scenario | Pattern |
|---|---|
| Regular price | |
| Sale price | Original: |
| Price range | |
| Currency symbol | Keep symbol adjacent, no wrapping: |
| 场景 | 实现模式 |
|---|---|
| 常规价格 | |
| 促销价格 | 原价: |
| 价格区间 | 前缀用 |
| 货币符号 | 不换行: |
Rating Display
评分展示
| Element | Classes |
|---|---|
| Star icon (filled) | |
| Star icon (empty) | |
| Half star | Clip filled star at 50% with |
| Review count | |
| Container | |
| 元素 | 类名 |
|---|---|
| 实心星星图标 | |
| 空心星星图标 | |
| 半星 | 用 |
| 评价数量 | 星星旁添加 |
| 容器 | |
2. Product List Layouts
2. 商品列表布局
Responsive Grid
响应式网格
html
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
<!-- Product cards -->
</div>html
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
<!-- 商品卡片 -->
</div>Layout Patterns
布局模式
| Layout | Classes | When to Use |
|---|---|---|
| Grid (default) | | Category pages, search results |
| Two-column wide | | Featured products, comparisons |
| List view | | Detail-heavy browsing |
| Masonry-style | | Visual-heavy catalogs |
| 布局类型 | 类名 | 使用场景 |
|---|---|---|
| 网格布局(默认) | | 分类页面、搜索结果 |
| 双列宽布局 | | 精选商品、商品对比 |
| 列表视图 | | 信息密集型浏览场景 |
| 瀑布流布局 | | 视觉导向型商品目录 |
Loading and Pagination
加载与分页
| Pattern | Implementation |
|---|---|
| Skeleton card | |
| Skeleton image | |
| Skeleton text | |
| Load more button | |
| Pagination | |
| Infinite scroll | Intersection observer on sentinel div at grid end |
| Empty state | |
| 模式 | 实现方式 |
|---|---|
| 骨架卡片 | |
| 骨架图片 | |
| 骨架文本 | |
| 加载更多按钮 | 网格下方添加 |
| 分页组件 | |
| 无限滚动 | 网格底部添加哨兵元素,结合交叉观察器实现 |
| 空状态 | |
3. Category and Filtering
3. 分类与筛选
Sidebar Filter Panel (Desktop)
侧边栏筛选面板(桌面端)
| Element | Classes |
|---|---|
| Panel container | |
| Filter group | |
| Group heading | |
| Checkbox + label | |
| Color swatch | |
| Price range | Two |
| Apply button | |
| 元素 | 类名 |
|---|---|
| 面板容器 | |
| 筛选组 | |
| 组标题 | |
| 复选框+标签 | |
| 颜色样本 | |
| 价格区间 | 两个 |
| 应用按钮 | |
Mobile Filter (Slide-out Dialog)
移动端筛选(滑出对话框)
| Element | Classes |
|---|---|
| Trigger button | |
| Backdrop | |
| Panel | |
| Header | |
| Footer | |
| 元素 | 类名 |
|---|---|
| 触发按钮 | |
| 遮罩层 | |
| 面板 | |
| 头部 | |
| 底部 | |
Active Filters and Sorting
已选筛选与排序
| Element | Classes |
|---|---|
| Filter chip | |
| Remove button | |
| Clear all link | |
| Sort dropdown | |
| Result count | |
| Filter count badge | |
| 元素 | 类名 |
|---|---|
| 筛选标签 | |
| 移除按钮 | |
| 清除全部链接 | |
| 排序下拉框 | |
| 结果数量 | |
| 筛选数量徽章 | |
4. Shopping Cart
4. 购物车
Cart Item Row
购物车商品行
html
<div class="flex gap-4 py-4 border-b">
<img class="size-20 rounded-lg object-cover shrink-0" src="..." alt="..." />
<div class="flex flex-1 flex-col justify-between">
<div class="flex justify-between">
<div>
<h3 class="text-sm font-medium text-gray-900">Product Name</h3>
<p class="mt-1 text-sm text-gray-500">Color / Size</p>
</div>
<p class="text-sm font-medium text-gray-900">$49.99</p>
</div>
<div class="flex items-center justify-between">
<!-- Quantity selector -->
<div class="flex items-center rounded-lg border">
<button class="px-3 py-1 text-gray-600">-</button>
<span class="px-3 py-1 border-x text-sm">1</span>
<button class="px-3 py-1 text-gray-600">+</button>
</div>
<button class="text-sm text-red-600 hover:text-red-800">Remove</button>
</div>
</div>
</div>html
<div class="flex gap-4 py-4 border-b">
<img class="size-20 rounded-lg object-cover shrink-0" src="..." alt="..." />
<div class="flex flex-1 flex-col justify-between">
<div class="flex justify-between">
<div>
<h3 class="text-sm font-medium text-gray-900">Product Name</h3>
<p class="mt-1 text-sm text-gray-500">Color / Size</p>
</div>
<p class="text-sm font-medium text-gray-900">$49.99</p>
</div>
<div class="flex items-center justify-between">
<!-- 数量选择器 -->
<div class="flex items-center rounded-lg border">
<button class="px-3 py-1 text-gray-600">-</button>
<span class="px-3 py-1 border-x text-sm">1</span>
<button class="px-3 py-1 text-gray-600">+</button>
</div>
<button class="text-sm text-red-600 hover:text-red-800">Remove</button>
</div>
</div>
</div>Cart Sections
购物车区域
| Section | Classes | Content |
|---|---|---|
| Cart list | | Cart item rows |
| Summary panel | | Subtotal, shipping, tax, total |
| Summary row | | Label + amount |
| Total row | | Total label + amount |
| Checkout CTA | | "Proceed to Checkout" |
| Continue shopping | | Link back |
| 区域 | 类名 | 内容 |
|---|---|---|
| 购物车列表 | | 购物车商品行 |
| 摘要面板 | | 小计、运费、税费、总计 |
| 摘要行 | | 标签+金额 |
| 总计行 | | 总计标签+金额 |
| 结账按钮 | | "Proceed to Checkout"(前往结账) |
| 继续购物 | | 返回链接 |
Cart States
购物车状态
| State | Pattern |
|---|---|
| Empty cart | |
| Mini cart / drawer | |
| Cart badge | |
| Updating state | |
| 状态 | 实现模式 |
|---|---|
| 空购物车 | |
| 迷你购物车/抽屉 | |
| 购物车徽章 | |
| 更新状态 | 异步更新时,商品行添加 |
5. Checkout Flow
5. 结账流程
Progress Indicator
进度指示器
| Step State | Classes |
|---|---|
| Completed | |
| Current | |
| Upcoming | |
| Connector (done) | |
| Connector (pending) | |
| Container | |
| 步骤状态 | 类名 |
|---|---|
| 已完成 | |
| 当前步骤 | |
| 未开始 | |
| 连接线(已完成) | 圆圈间添加 |
| 连接线(未开始) | 圆圈间添加 |
| 容器 | |
Form Layout
表单布局
| Section | Structure |
|---|---|
| Two-column layout | |
| Field group | |
| Two-field row | |
| Full-width field | |
| Label | |
| Input | |
| Error input | |
| Error message | |
| 区域 | 结构 |
|---|---|
| 双列布局 | |
| 字段组 | |
| 双字段行 | |
| 全宽字段 | |
| 标签 | |
| 输入框 | |
| 错误输入框 | |
| 错误提示 | |
Payment Fields
支付字段
| Element | Pattern |
|---|---|
| Card number | Full-width input with card icon right-aligned |
| Expiry + CVC | |
| Card group | |
| Saved cards | Radio group: |
| Security note | |
| 元素 | 实现模式 |
|---|---|
| 卡号 | 全宽输入框+右侧卡片图标 |
| 有效期+CVC | |
| 卡片组 | |
| 已保存卡片 | 单选组:每个卡片用 |
| 安全提示 | |
Checkout Patterns
结账模式
| Pattern | Implementation |
|---|---|
| Guest vs account | Toggle or tabs at top: |
| Order review | Summary card: item thumbnails, quantities, line totals in |
| Place order CTA | |
| Terms checkbox | |
| Loading on submit | Button with |
| 模式 | 实现方式 |
|---|---|
| 访客/账号切换 | 顶部切换或标签页: |
| 订单回顾 | 摘要卡片: |
| 提交订单按钮 | |
| 条款复选框 | |
| 提交加载状态 | 按钮添加 |
6. Order Management
6. 订单管理
Order History Table
订单历史表格
| Viewport | Pattern |
|---|---|
| Desktop | Standard |
| Mobile | Stacked cards: |
| Table header | |
| Table cell | |
| 视口 | 实现模式 |
|---|---|
| 桌面端 | 标准 |
| 移动端 | 堆叠卡片: |
| 表头 | |
| 表格单元格 | |
Order Status Badges
订单状态徽章
| Status | Classes |
|---|---|
| Pending | |
| Processing | |
| Shipped | |
| Delivered | |
| Cancelled | |
| Refunded | |
| 状态 | 类名 |
|---|---|
| 待处理 | |
| 处理中 | |
| 已发货 | |
| 已送达 | |
| 已取消 | |
| 已退款 | |
Order Detail Page
订单详情页
| Section | Pattern |
|---|---|
| Status timeline | Vertical: |
| Timeline dot (done) | |
| Timeline dot (current) | |
| Timeline line | |
| Items list | Horizontal cards with image, name, qty, price |
| Totals section | Same pattern as cart summary |
| Shipping address | |
| Invoice layout | |
| 区域 | 实现模式 |
|---|---|
| 状态时间线 | 垂直布局: |
| 时间线圆点(已完成) | |
| 时间线圆点(当前) | |
| 时间线连接线 | |
| 商品列表 | 横向卡片,包含图片、名称、数量、价格 |
| 总计区域 | 与购物车摘要模式相同 |
| 收货地址 | |
| 发票布局 | |
7. Pricing and Promotions
7. 价格与促销
Price Patterns
价格模式
| Pattern | Implementation |
|---|---|
| Original + sale | |
| Save amount | |
| Per-unit price | |
| 模式 | 实现方式 |
|---|---|
| 原价+现价 | |
| 优惠金额 | |
| 单价 | 主价格下方添加 |
Discount Badge (on Product Image)
商品图片上的折扣徽章
html
<div class="relative">
<img class="aspect-[3/4] w-full rounded-lg object-cover" src="..." alt="..." />
<span class="absolute top-2 left-2 rounded-full bg-red-600 px-2.5 py-0.5 text-xs font-semibold text-white">
-50%
</span>
</div>html
<div class="relative">
<img class="aspect-[3/4] w-full rounded-lg object-cover" src="..." alt="..." />
<span class="absolute top-2 left-2 rounded-full bg-red-600 px-2.5 py-0.5 text-xs font-semibold text-white">
-50%
</span>
</div>Pricing Tier Cards
价格层级卡片
| Element | Classes |
|---|---|
| Card container | |
| Featured card | |
| Price | |
| Period | |
| Feature list | |
| CTA button | |
| 元素 | 类名 |
|---|---|
| 卡片容器 | |
| 精选卡片 | |
| 价格 | |
| 周期 | |
| 功能列表 | |
| 操作按钮 | |
Promo and Incentive Sections
促销与激励区域
| Pattern | Classes |
|---|---|
| Full-width banner | |
| Dismissable banner | Add |
| Trust icons row | |
| Trust icon item | |
| Coupon input | |
| 模式 | 类名 |
|---|---|
| 通栏横幅 | |
| 可关闭横幅 | 添加 |
| 信任图标行 | |
| 信任图标项 | |
| 优惠券输入框 | |
8. Store Navigation
8. 店铺导航
Store Header
店铺头部
| Element | Classes |
|---|---|
| Header bar | |
| Inner layout | |
| Logo | |
| Search bar | |
| Icon group | |
| Cart icon + badge | |
| 元素 | 类名 |
|---|---|
| 头部栏 | |
| 内部布局 | |
| Logo | |
| 搜索栏 | |
| 图标组 | |
| 购物车图标+徽章 | 按钮添加 |
Mega Menu
超级菜单
| Element | Classes |
|---|---|
| Trigger | |
| Dropdown | |
| Inner grid | |
| Column heading | |
| Column links | |
| Featured image | |
| 元素 | 类名 |
|---|---|
| 触发器 | 导航项添加 |
| 下拉菜单 | |
| 内部网格 | |
| 列标题 | |
| 列链接 | |
| 精选图片 | 最后一列添加 |
Category Previews and Breadcrumbs
分类预览与面包屑
| Element | Classes |
|---|---|
| Category card | |
| Category image | |
| Category overlay | |
| Category label | |
| Breadcrumb nav | |
| Breadcrumb separator | |
| Breadcrumb current | |
| 元素 | 类名 |
|---|---|
| 分类卡片 | |
| 分类图片 | |
| 分类遮罩 | |
| 分类标签 | |
| 面包屑导航 | |
| 面包屑分隔符 | |
| 当前面包屑 | |
9. Accessibility for Ecommerce
电商界面无障碍设计
| Element | Requirement | Implementation |
|---|---|---|
| Product image | Descriptive alt text | |
| Decorative image | Skip for screen readers | |
| Sale price | Announce was/now | |
| Cart update | Announce change | |
| Cart count badge | Announce count | |
| Quantity selector | Label buttons | |
| Star rating | Text alternative | |
| Filter change | Announce results | |
| Form errors | Link to field | |
| Checkout steps | Current step | |
| Remove from cart | Confirm action | Identify item in label: |
| Sort dropdown | Label purpose | |
| Color swatch | Name the color | |
| Dialog filters | Trap focus | |
| 元素 | 要求 | 实现方式 |
|---|---|---|
| 商品图片 | 描述性替代文本 | |
| 装饰性图片 | 屏幕阅读器跳过 | |
| 促销价格 | 播报原价/现价 | 容器添加 |
| 购物车更新 | 播报变化 | 添加 |
| 购物车数量徽章 | 播报数量 | 购物车按钮添加 |
| 数量选择器 | 按钮添加标签 | |
| 星级评分 | 文本替代 | 评分容器添加 |
| 筛选变化 | 播报结果 | 商品数量添加 |
| 表单错误 | 链接到字段 | 输入框添加 |
| 结账步骤 | 当前步骤 | 激活步骤指示器添加 |
| 从购物车移除 | 确认操作 | 标签中明确商品: |
| 排序下拉框 | 说明用途 | 选择元素添加 |
| 颜色样本 | 命名颜色 | 样本按钮添加 |
| 对话框筛选 | 焦点捕获 | 移动端筛选面板添加 |
Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
| Fixed pixel image heights | Use |
| Cart with no empty state | Always handle zero items with illustration and CTA |
Price without | Currency and amount should not wrap to separate lines |
| Filter panel always visible on mobile | Hide with |
| No loading state during cart updates | Show |
| Checkout form in single column | Use |
| Status badges with only color | Add text labels; color alone fails WCAG |
Missing | Cart count and summary changes must announce to screen readers |
| Mega menu not keyboard-navigable | Ensure focus management and Escape key closes the menu |
| Discount badge over product text | Position badge on image ( |
| 错误 | 修复方案 |
|---|---|
| 固定像素图片高度 | 用 |
| 购物车无空状态 | 始终处理零商品场景,添加插图和引导按钮 |
价格未添加 | 货币和金额不应换行 |
| 移动端始终显示筛选面板 | 用 |
| 购物车更新无加载状态 | 异步操作时,添加 |
| 结账表单单列布局 | 姓名、城市/邮编、有效期/CVC对等字段用 |
| 状态徽章仅用颜色区分 | 添加文本标签;仅靠颜色不符合WCAG标准 |
购物车缺少 | 购物车数量和摘要变化时,需向屏幕阅读器播报 |
| 超级菜单不支持键盘导航 | 确保焦点管理和Escape键关闭菜单 |
| 折扣徽章覆盖商品文本 | 徽章定位在图片上( |
MCP Component Library
MCP组件库
The MCP server provides ecommerce-related components:
frontend-components- HyperUI (): Product cards, product collections, pricing tables, forms, badges, stats
hyperui - DaisyUI (): Card, badge, stat, table, modal, rating, countdown class references
daisyui - FlyonUI (): Card, badge, stat, table CSS components + datatable JS plugin
flyonui
Ecommerce search: or for pricing components across all libraries.
search_components(query: "product", framework: "hyperui")search_components(query: "pricing")frontend-components- HyperUI ():商品卡片、商品集合、价格表、表单、徽章、统计组件
hyperui - DaisyUI ():卡片、徽章、统计、表格、模态框、评分、倒计时类参考
daisyui - FlyonUI ():卡片、徽章、统计、表格CSS组件 + 数据表格JS插件
flyonui
电商组件搜索: 或 可跨库搜索价格类组件。
search_components(query: "product", framework: "hyperui")search_components(query: "pricing")