Skip to content

Space 间距

用于对多个元素进行间距与排布控制,支持方向、换行与对齐。

基础用法

vue
<template>
  <ex-space>
    <ex-button>按钮1</ex-button>
    <ex-button>按钮2</ex-button>
    <ex-button>按钮3</ex-button>
  </ex-space>
</template>

方向与尺寸

vue
<template>
  <ex-space direction="horizontal" size="small">
    <ex-button>small</ex-button><ex-button>small</ex-button>
  </ex-space>
  <ex-space direction="horizontal" size="large">
    <ex-button>large</ex-button><ex-button>large</ex-button>
  </ex-space>
  <ex-space direction="vertical" size="medium">
    <ex-button>vertical A</ex-button><ex-button>vertical B</ex-button>
  </ex-space>
</template>

换行与对齐

vue
<template>
  <ex-space wrap justify="space-between" align="center" style="max-width: 360px;">
    <ex-button>1</ex-button><ex-button>2</ex-button><ex-button>3</ex-button>
    <ex-button>4</ex-button><ex-button>5</ex-button>
  </ex-space>
</template>

API

Props

参数说明类型默认值
direction方向'horizontal' | 'vertical''horizontal'
size间距'small' | 'medium' | 'large' | number'medium'
wrap是否换行booleanfalse
align交叉轴对齐'start' | 'center' | 'end''start'
justify主轴对齐'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly''start'

Slots

名称说明
default子元素

Exposes

方法名说明
getElement获取根元素

主题定制

css
:root {
  --ex-space-gap-small: 8px;
  --ex-space-gap-medium: 12px;
  --ex-space-gap-large: 16px;
}

无障碍与国际化

  • Space 作为布局容器无语义,必要时请为内部元素提供合理 aria 属性与键盘可用性。