Space 间距
给组件之间提供统一的间距。
基础用法
间距组件的基本用法。
<template>
<tu-space>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
</template>
<template>
<tu-space>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
</template>
垂直间距
可以设置垂直方向排列的间距。
<template>
<tu-space :size="12" direction="vertical" fill>
<tu-button long>按钮1</tu-button>
<tu-button long>按钮2</tu-button>
<tu-button long>按钮3</tu-button>
</tu-space>
</template>
<template>
<tu-space :size="12" direction="vertical" fill>
<tu-button long>按钮1</tu-button>
<tu-button long>按钮2</tu-button>
<tu-button long>按钮3</tu-button>
</tu-space>
</template>
尺寸
内置 4 个尺寸,mini - 4px small - 8px (默认) medium - 16px large - 24px,也支持传数字来自定义尺寸。
<template>
<tu-radio-group class="mb-2" v-model="size" type="button">
<tu-radio label="mini">超小</tu-radio>
<tu-radio label="small">较小</tu-radio>
<tu-radio label="medium">中等</tu-radio>
<tu-radio label="large">较大</tu-radio>
</tu-radio-group>
<br />
<tu-space :size="size">
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const size = ref('medium');
</script>
<template>
<tu-radio-group class="mb-2" v-model="size" type="button">
<tu-radio label="mini">超小</tu-radio>
<tu-radio label="small">较小</tu-radio>
<tu-radio label="medium">中等</tu-radio>
<tu-radio label="large">较大</tu-radio>
</tu-radio-group>
<br />
<tu-space :size="size">
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const size = ref('medium');
</script>
对齐
内置 4 种对齐方式,分别为 start、center、end、 baseline,在水平模式下默认为 center。
渭城朝雨浥轻尘,客舍青青柳色新。
劝君更尽一杯酒,西出阳关无故人。
<template>
<tu-radio-group class="mb-2" v-model="align" type="button">
<tu-radio label="start">头部对齐</tu-radio>
<tu-radio label="center">中间对齐</tu-radio>
<tu-radio label="end">尾部对齐</tu-radio>
<tu-radio label="baseline">基础线对齐</tu-radio>
</tu-radio-group>
<br />
<tu-space :align="align">
<tu-card>
<p style="line-height: 1">渭城朝雨浥轻尘,客舍青青柳色新。</p>
<p style="line-height: 1">劝君更尽一杯酒,西出阳关无故人。</p>
</tu-card>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
</tu-space>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const align = ref('start');
</script>
<template>
<tu-radio-group class="mb-2" v-model="align" type="button">
<tu-radio label="start">头部对齐</tu-radio>
<tu-radio label="center">中间对齐</tu-radio>
<tu-radio label="end">尾部对齐</tu-radio>
<tu-radio label="baseline">基础线对齐</tu-radio>
</tu-radio-group>
<br />
<tu-space :align="align">
<tu-card>
<p style="line-height: 1">渭城朝雨浥轻尘,客舍青青柳色新。</p>
<p style="line-height: 1">劝君更尽一杯酒,西出阳关无故人。</p>
</tu-card>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
</tu-space>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const align = ref('start');
</script>
环绕间距
环绕类型的间距,四周都有间距,一般用于换行的场景。
<template>
<tu-space wrap>
<tu-button v-for="i in 10" :key="i">按钮 {{ i + 1 }}</tu-button>
</tu-space>
</template>
<template>
<tu-space wrap>
<tu-button v-for="i in 10" :key="i">按钮 {{ i + 1 }}</tu-button>
</tu-space>
</template>
分隔符
为相邻子元素设置分隔符。
<template>
<tu-space class="mb-2">
<template #divider>
<tu-divider direction="vertical" />
</template>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
<br />
<tu-space class="mb-2">
<template #divider>
<tu-icon style="margin: 0 6px"><Pouring /></tu-icon>
</template>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
</template>
<script lang="ts" setup>
import { Pouring } from '@tu-view-plus/icons-vue';
</script>
<template>
<tu-space class="mb-2">
<template #divider>
<tu-divider direction="vertical" />
</template>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
<br />
<tu-space class="mb-2">
<template #divider>
<tu-icon style="margin: 0 6px"><Pouring /></tu-icon>
</template>
<tu-button>按钮1</tu-button>
<tu-button>按钮2</tu-button>
<tu-button>按钮3</tu-button>
</tu-space>
</template>
<script lang="ts" setup>
import { Pouring } from '@tu-view-plus/icons-vue';
</script>
Space API
Space Attributes
参数名 | 描述 | 类型 | 默认值 |
---|---|---|---|
align | 对齐方式 | String | - |
direction | 间距方向 | String | horizontal |
size | 间距大小,支持分别制定横向和竖向的间距 | String | 'small' |
wrap | 环绕类型的间距,用于折行的场景。 | Boolean | false |
fill | 充满整行 | Boolean | false |
Radio Slots
参数名 | 描述 |
---|---|
divider | 设置分隔符 |