布局
@astryxdesign/core v0.7.1 · Layout
Layout Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
contentWidth | number | string | - | 对齐内容的最大宽度。分隔线仍然拉满。数字按像素处理。百分比、fit-content、max-content、min-content 或裸 var() 走约束宽度。 |
height | 'fill' | 'auto' | 'fill' | fill 撑满容器,正文在中间滚动。auto 随内容长高。 |
padding | SpacingStep | - | 只作用于这一层的外缘间距,不传给嵌套的布局。0 表示通栏。 |
defaultHasDividers | boolean | - | 页眉或页脚没有写 hasDivider 时用的默认值。 |
SpacingStep 的取值是 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10。
Layout 插槽
| 名称 | 说明 |
|---|---|
default | 正文区域。这里放 LayoutContent。 |
header | 顶部区域。这里放 LayoutHeader。 |
start | 行起始边。这里放 LayoutPanel。面板可拖拽时,旁边再放 ResizeHandle。 |
end | 行结束边。 |
footer | 底部区域。这里放 LayoutFooter。 |
Layout Header Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
hasDivider | boolean | 继承 | 底边分隔线。不传时用 defaultHasDividers;布局也没写时是 false。 |
height | number | string | - | 高度。数字按像素处理,字符串原样使用。 |
padding | SpacingStep | - | 内边距。0 表示内容自己管边距。 |
paddingBlockEnd | SpacingStep | - | 只改底边内边距,方便标签下划线和分隔线贴住。 |
label | string | - | 设置了 role 时的无障碍名称。 |
role | AriaRole | - | ARIA 地标角色。 |
LayoutHeader 有一个默认插槽,放页眉内容。
Layout Footer Props
LayoutFooter 接受 hasDivider、height、padding、label、role,含义和页眉相同。hasDivider 画在顶边。它有一个默认插槽。
Layout Content Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
padding | SpacingStep | - | 内边距。0 让 Section 这类子元素铺到边缘。 |
isScrollable | boolean | true | 内容超出时在这块里滚动。 |
label | string | - | 设置了 role 时的无障碍名称。 |
role | AriaRole | - | ARIA 地标角色。 |
LayoutContent 有一个默认插槽。
Layout Panel Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
hasDivider | boolean | false | 朝向正文的那条边。旁边的 ResizeHandle 已经画线时不要再开。 |
padding | SpacingStep | - | 内边距。不传、而且没有分隔线时,朝向正文的外边距会收起来。 |
isScrollable | boolean | true | 内容超出时在面板里滚动。 |
width | number | string | - | 宽度。数字按像素处理。传了 resizable 时以钩子的尺寸为准。 |
resizable | LayoutResizable | - | useResizable 返回的 props。面板宽度跟着 _size;对象里还带着这块区域的轴 _direction('horizontal' | 'vertical'),要和旁边的 ResizeHandle 一致。 |
label | string | - | 设置了 role 时的无障碍名称。 |
role | AriaRole | - | ARIA 地标角色,例如 navigation。 |
LayoutPanel 有一个默认插槽。
原生属性
每一块的根元素都是 <div>。
以下内容落到各自的根上:
- HTML 属性。
aria-*属性。data-*属性。class。style。
class 会合并。Layout 写 data-height。