侧栏
sidebar
分组可折叠(grid 0fr↔1fr 动画,chevron 随开合旋转),条目支持图标与 .is-active。
示例
<aside class="sidebar">
<div class="sidebar-group is-open">
<button class="sidebar-group-title" aria-expanded="true">快速开始</button>
<div class="sidebar-group-panel"><div class="sidebar-group-panel-inner">
<a class="sidebar-item" href="#">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h9"/><path d="m16 19 2 2 4-4"/></svg>
<span>安装</span>
</a>
<a class="sidebar-item is-active" href="#">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/></svg>
<span>快速上手</span>
</a>
</div></div>
</div>
<div class="sidebar-group">
<button class="sidebar-group-title" aria-expanded="false">进阶指南</button>
<div class="sidebar-group-panel"><div class="sidebar-group-panel-inner">
<a class="sidebar-item" href="#">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>
<span>更新日志</span>
</a>
</div></div>
</div>
</aside> 安装
bun add @icen.ai/ui
import '@icen.ai/ui/components/sidebar.css'; 用法
import { initSidebar } from '@icen.ai/ui/behaviors/sidebar';
initSidebar(); // 点击 .sidebar-group-title 切父 group 的 .is-open + aria-expanded