Skip to content

Layout 布局

Layout 组件库提供了一系列用于页面布局的基础组件,包括 BoxStackGrid。这些组件都支持响应式属性,可以轻松构建复杂的响应式布局。

Box

Box 是最基础的布局组件,它本质上是一个可以自定义标签并支持原子化 CSS 属性的容器。

SXO Framework Switcher
🚧
This example is not yet available for .

Stack

Stack 用于水平或垂直排列子元素,底层基于 Flexbox。

SXO Framework Switcher
🚧
This example is not yet available for .

Grid

Grid 用于创建网格布局,底层基于 CSS Grid。

SXO Framework Switcher
🚧
This example is not yet available for .

Container

Container 用于限制内容的最大宽度,并使其在页面中居中。

SXO Framework Switcher
🚧
This example is not yet available for .

响应式支持

所有布局组件的属性都支持响应式对象写法。

断点描述
base默认样式 (mobile first)
sm>= 640px
md>= 768px
lg>= 1024px
xl>= 1280px
2xl>= 1536px

API

Box Props

属性类型默认值说明
asstring'div'渲染的 HTML 标签
paddingResponsive<string | number>-内边距
marginResponsive<string | number>-外边距
bgResponsive<string>-背景色
roundedResponsive<string>-圆角
shadowResponsive<string>-阴影
widthResponsive<string | number>-宽度
heightResponsive<string | number>-高度
.........支持更多原子化 CSS 属性

Stack Props

属性类型默认值说明
directionResponsive<'row' | 'col'>'col'排列方向
gapResponsive<string | number>4间距
alignResponsive<'start' | 'center' | 'end' | 'baseline' | 'stretch'>'stretch'侧轴对齐方式
justifyResponsive<'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'>'start'主轴对齐方式
wrapResponsive<boolean>false是否换行

Grid Props

属性类型默认值说明
colsResponsive<number>-列数
rowsResponsive<number>-行数
gapResponsive<string | number>4间距
flowResponsive<'row' | 'col' | 'dense' | 'row-dense' | 'col-dense'>'row'网格流向

API

参数说明类型默认值
direction-[String'col'
gap-[String4
align-[String'stretch'
justify-[String'start'
wrap-[Booleanfalse