feat(ui): Layout 新增 toolbar 插槽

页头与页身之间的一条真实占位带(搜索 / 筛选 / 操作),宽度跟随容器,
contained 时与侧栏 + 内容同宽,height=screen 下不参与内容区滚动。
用它替代「搜索框 fixed + contentOffset 让位」的写法。

- Layout.tsx / Layout.module.css:新增 toolbar prop 与样式
- 展示页 #layout 增加「页头下的工具条」示例
- COMPONENTS.md 补契约、与 contentOffset 的分工说明、changelog
This commit is contained in:
2026-11-01 15:15:14 +08:00
parent ebe4af3dab
commit 93bb5cbb28
5 changed files with 73 additions and 1 deletions
+13
View File
@@ -562,6 +562,19 @@ code {
gap: var(--su-space-1);
}
/* 工具条:页头与页身之间的一条搜索带(toolbar 插槽) */
.layout-toolbar {
display: flex;
align-items: center;
justify-content: center;
padding: var(--su-space-3) var(--su-space-5);
border-bottom: 1px solid var(--su-border);
}
.layout-toolbar > * {
width: min(360px, 100%);
}
.layout-side {
display: flex;
flex-direction: column;
+42 -1
View File
@@ -1,5 +1,5 @@
import { useState } from 'react'
import { Card, Grid, Layout, Segmented, Space, Tag, Text, Title } from '../../src'
import { Card, Grid, Input, Layout, Segmented, Space, Tag, Text, Title } from '../../src'
import { Demo } from '../components/Demo'
import { PropsTable } from '../components/PropsTable'
import { Section } from '../components/Section'
@@ -214,9 +214,50 @@ export function PageLayout() {
</div>
</Demo>
<Demo
title="页头下的工具条"
desc="toolbar 是真实占位的一层:宽度跟随容器,坐在页头与页身之间;整屏模式下它不参与内容区滚动,搜索框不用再 fixed + 手算 offset。"
layout="column"
code={`<Layout
header={<Header />}
toolbar={<Search />}
sider={<Nav />}
height="screen"
scrollable
>
<Content />
</Layout>`}
>
<div className="layout-frame" style={{ height: 320, overflow: 'hidden' }}>
<Layout
header={<DemoHeader />}
toolbar={
<div className="layout-toolbar">
<Input size="lg" icon="search_3_line" placeholder="搜索本地项目…" readOnly />
</div>
}
sider={<DemoSider compact />}
headerHeight={56}
height="screen"
scrollable
hideScrollbar
style={{ height: 320 }}
>
<div className="layout-content">
{Array.from({ length: 6 }, (_, index) => (
<Card padding="md" key={index}>
<Text size="sm">第 {index + 1} 行:工具条固定在页头下方,只有这里滚动。</Text>
</Card>
))}
</div>
</Layout>
</div>
</Demo>
<PropsTable
rows={[
{ name: 'header', type: 'ReactNode', desc: '页头,默认吸顶' },
{ name: 'toolbar', type: 'ReactNode', desc: '页头与页身之间的工具条(搜索 / 筛选 / 操作带),宽度随容器' },
{ name: 'sider', type: 'ReactNode', desc: '左侧栏,固定宽度' },
{ name: 'aside', type: 'ReactNode', desc: '右侧栏,固定宽度(目录 / 聚合 / 广告位)' },
{ name: 'footer', type: 'ReactNode', desc: '页脚' },