Skip to content

Stack 堆叠布局

用于垂直或水平排列元素的布局组件,基于 Flexbox。支持响应式布局并通过 BrConfigProvider 进行全局主题配置。

基础用法

垂直堆叠

默认情况下,BrStack 垂直排列元素(flex-col)。

Item 1
Item 2
Item 3
Example

水平堆叠与对齐

使用 direction="horizontal" 进行水平排列,并通过 alignjustify 控制对齐。

1
2
3
Example

响应式与自定义样式

BrStack 支持响应式属性(对象语法)和样式定制(圆角、阴影、内边距)。

Item 1
Item 2
Item 3
Example

多态渲染

使用 as 属性更改 Stack 的底层 HTML 元素,例如 ullisection 以实现语义化标记。

  • Item 1 (rendered as li)
  • Item 2 (rendered as li)
  • Item 3 (rendered as li)

Section Title

This entire stack is rendered as a <section> element.

Example

主题定制

Stack 的全局基础样式(如圆角)可以通过 BrConfigProvider 控制。

Default Theme (Radius: 0.5rem)
Custom Theme (Radius: 1.0rem)
Example

API

属性名说明类型默认值
as渲染的 HTML 标签stringdiv
direction布局方向'vertical' | 'horizontal' | ResponsiveProp'vertical'
gap元素间距string | number | ResponsiveProp-
align交叉轴对齐'start' | 'end' | 'center' | 'baseline' | 'stretch' | ResponsiveProp'stretch'
justify主轴对齐'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | ResponsiveProp'start'
wrap换行行为'nowrap' | 'wrap' | 'wrap-reverse' | ResponsiveProp'nowrap'
padding内边距string | number | ResponsiveProp-
radius圆角string | number | ResponsiveProp-
shadow阴影string | ResponsiveProp-