ICEN UI 表格
Docs ⌘K
Core · 稳定

表格

基础表格:窄屏横向滚动、行悬停、斑马纹与首列粘滞。

Preview
数据展示 table
服务实例清单 · 2026 年 7 月
名称区域状态实例数操作
gatewayus-east-1运行中4
accountsus-west-2运行中2
billingeu-west-1降级2
archiveap-northeast-1已停止0
searchus-east-1运行中6
合计14
html
<div class="icen-table-wrap icen-table-wrap--bordered">  <table class="icen-table icen-table--zebra">    <caption class="icen-table-caption">服务实例清单 · 2026 年 7 月</caption>    <thead>      <tr><th>名称</th><th>区域</th><th>状态</th><th class="icen-num">实例数</th><th class="icen-ops">操作</th></tr>    </thead>    <tbody>      <tr><td>gateway</td><td>us-east-1</td><td><span class="icen-pill icen-pill--success">运行中</span></td><td class="icen-num">4</td><td class="icen-ops"><button class="icen-btn icen-btn-sm">编辑</button><button class="icen-btn icen-btn-sm">停用</button></td></tr>      <tr><td>accounts</td><td>us-west-2</td><td><span class="icen-pill icen-pill--success">运行中</span></td><td class="icen-num">2</td><td class="icen-ops"><button class="icen-btn icen-btn-sm">编辑</button><button class="icen-btn icen-btn-sm">停用</button></td></tr>      <tr class="icen-row-warning"><td>billing</td><td>eu-west-1</td><td><span class="icen-pill icen-pill--warning">降级</span></td><td class="icen-num">2</td><td class="icen-ops"><button class="icen-btn icen-btn-sm">编辑</button><button class="icen-btn icen-btn-sm">停用</button></td></tr>      <tr class="icen-row-error"><td>archive</td><td>ap-northeast-1</td><td><span class="icen-pill icen-pill--error">已停止</span></td><td class="icen-num">0</td><td class="icen-ops"><button class="icen-btn icen-btn-sm">编辑</button><button class="icen-btn icen-btn-sm">启用</button></td></tr>      <tr><td>search</td><td>us-east-1</td><td><span class="icen-pill icen-pill--success">运行中</span></td><td class="icen-num">6</td><td class="icen-ops"><button class="icen-btn icen-btn-sm">编辑</button><button class="icen-btn icen-btn-sm">停用</button></td></tr>    </tbody>    <tfoot>      <tr><td colspan="3">合计</td><td class="icen-num">14</td><td></td></tr>    </tfoot>  </table></div>

特性

接口

初始化
initTableSort()(kit 一行入口可直接命名导入)
导出
initTableSort 共享行为模块,清单含族内导出
事件
icen:check-changeicen:page-changeicen:rating-changeicen:segmented-changeicen:sort-changeicen:step-changeicen:stepper-changeicen:switch-change detail 契约见 IcenEventMap;共享行为模块,清单含族内事件
类型
dist/behaviors/controls.d.mts(随 npm 包发布,含全部 JSDoc 约束)

安装

bun add @icen.ai/ui

一行引入该组件(CSS 与 behavior 自动带上,无需关心内部 CSS 文件名):

js
import '@icen.ai/ui/kit/table';import { initTableSort } from '@icen.ai/ui';initTableSort();

也可以用脚手架直接打印引入行:

bash
bunx --bun @icen.ai/ui add table

Astro 项目注意:kit 入口里的 CSS import 在页面 <script> 里会被 Astro 的 client bundle 摇掉——请改在布局 frontmatter 里引 CSS(import '@icen.ai/ui/components/table.css';),JS 行为仍可走 kit。Vite SPA / webpack 项目无此问题。

用法

html
<div class="icen-table-wrap [--bordered]">  <table class="icen-table [--zebra] [--compact|--dense] [--sticky-col]">    <caption class="icen-table-caption">标题</caption>    <thead><tr><th>名称</th><th class="icen-ops">操作</th></tr></thead>    <tbody>      <tr class="icen-row-link [.is-selected] [.row-success|.row-warning|.row-error]">        <td>gateway</td>        <td class="icen-ops"><button class="icen-btn icen-btn-sm">编辑</button></td>      </tr>    </tbody>    <tfoot><tr><td>合计</td></tr></tfoot>  </table></div>