Space 间距
设置组件之间的间距。
基本用法
base.vue
tsconfig.json
Import Map
xxxxxxxxxx
13
<script setup lang="ts">
import { Space, Switch, Button } from '@kousum/semi-ui-vue';
</script>
<template>
<Space>
<Switch :defaultChecked="true" />
<Button type="secondary">次要</Button>
<Button type="tertiary">第三</Button>
<Button type="warning">警告</Button>
</Space>
</template>
Show Error
Auto Save
对齐方式
可使用 align
设置对齐方式,可选值:start
、center
(默认)、end
、baseline
。
alignDemo.vue
tsconfig.json
Import Map
xxxxxxxxxx
41
<template>
<Space vertical>
<Space align='start'>
<div :style="divStyle">文本</div>
<Button theme='solid' type='primary'>按钮</Button>
<Tag color='green' size='large'>标签</Tag>
</Space>
<Space align='center'>
<div :style="divStyle">文本</div>
<Button theme='solid' type='primary'>按钮</Button>
<Tag color='green' size='large'>标签</Tag>
</Space>
<Space align='end'>
<div :style="divStyle">文本</div>
<Button theme='solid' type='primary'>按钮</Button>
<Tag color='green' size='large'>标签</Tag>
</Space>
<Space align='baseline'>
<div :style="divStyle">文本</div>
<Button theme='solid' type='primary'>按钮</Button>
<Tag color='green' size='large'>标签</Tag>
</Space>
</Space>
</template>
<script setup>
import { ref } from 'vue';
import { Space, Button, Tag } from '@kousum/semi-ui-vue';
Show Error
Auto Save
间距尺寸
可使用 spacing
设置间距大小,内置可选值:tight
(8px,默认)、medium
(16px)、loose
(24px),并且支持传入 number 来自定义间距大小,也支持传入 array 来同时设置水平和垂直方向的间距。
spacingDemo.vue
tsconfig.json
Import Map
xxxxxxxxxx
47
<template>
<Tabs type="line">
<TabPane tab="tight" itemKey="1">
<Space :spacing="'tight'" style="margin-top: 15px">
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
</Space>
</TabPane>
<TabPane tab="medium" itemKey="2">
<Space :spacing="'medium'" style="margin-top: 15px">
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
</Space>
</TabPane>
<TabPane tab="loose" itemKey="3">
<Space :spacing="'loose'" style="margin-top: 15px">
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
Show Error
Auto Save
间距方向
可使用 vertical
设置间距是否为垂直方向,默认情况下为 false。
verticalDemo.vue
tsconfig.json
Import Map
xxxxxxxxxx
13
<template>
<Space vertical>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
<Button theme='solid' type='primary'>按钮</Button>
</Space>
</template>
<script setup lang="ts">
import { Space, Button } from '@kousum/semi-ui-vue';
</script>
Show Error
Auto Save
设置换行
当间距为水平方向时,可使用 wrap
设置是否自动换行,默认情况下为 false。
wrapDemo.vue
tsconfig.json
Import Map
xxxxxxxxxx
17
<template>
<Space wrap>
<Button
v-for="(item, index) in new Array(10).fill(null)"
:key="index"
theme="solid"
type="secondary"
>
按钮
</Button>
</Space>
</template>
<script setup>
import { Space, Button } from '@kousum/semi-ui-vue';
</script>
Show Error
Auto Save
API参考
属性 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
align | 对齐方式, 支持 start 、end 、center 、baseline | string | center | >=1.17.0 |
className | 样式类名 | string | - | >=1.17.0 |
spacing | 间距尺寸, 支持 loose 、medium 、tight 或 number、array | string|number|array | tight | >=1.17.0 |
style | 内联样式 | CSSProperties | - | >=1.17.0 |
vertical | 是否为垂直间距 | boolean | false | >=1.17.0 |
wrap | 是否自动换行 | boolean | false | >=1.17.0 |