Skip to content

Space

Use this component to provide uniform spacing between components.

Basic usage

The most basic usage, through this component to provide a uniform spacing between components.

vue
<template>
  <v-space wrap>
    <v-button v-for="key in 4" :key="key" theme="primary">
      Button
    </v-button>
  </v-space>
</template>

Control the size of the spacing

control the size of the spacing by adjusting the value of size

vue
<template>
  <v-space direction="column">
    <v-space wrap size="small">
      <v-button v-for="key in 4" :key="key" theme="primary">
        Button
      </v-button>
    </v-space>
    <v-space wrap size="medium">
      <v-button v-for="key in 4" :key="key" theme="primary">
        Button
      </v-button>
    </v-space>
    <v-space wrap size="large">
      <v-button v-for="key in 4" :key="key" theme="primary">
        Button
      </v-button>
    </v-space>
    <v-space wrap size="4rem">
      <v-button v-for="key in 4" :key="key" theme="primary">
        Button
      </v-button>
    </v-space>
  </v-space>
</template>

Arrangement direction

Vertical layout, use direction to control the way of layout, behind it is actually using flex-direction to control.

vue
<template>
  <v-space direction="column">
    <v-button v-for="key in 4" :key="key" theme="primary">
      Button
    </v-button>
  </v-space>
</template>

Automatic line wrapping

set automatic line wrapping via wrap control

vue
<template>
  <v-space wrap>
    <v-button v-for="key in 30" :key="key" theme="primary">
      Button
    </v-button>
  </v-space>
</template>

Alignment

controls the alignment of child nodes through align-items

stretch

center

start

end

normal

vue
<script setup lang="ts">
const alignItems = ['stretch', 'center', 'start', 'end', 'normal'];
</script>

<template>
  <template v-for="align in alignItems" :key="align">
    <v-space :align-items="align">
      <v-button v-for="key in 4" :key="key" theme="primary">
        Button
      </v-button>
      <div :style="{ height: '60px', border: '1px solid red', background: 'gray' }">
        {{ align }}
      </div>
    </v-space>
    <hr>
  </template>
</template>

Fill the whole line

controls the child node to fill the entire line through fill

vue
<template>
  <v-space fill>
    <v-button v-for="key in 4" :key="key" theme="primary">
      Button
    </v-button>
  </v-space>
</template>

API

space attribute

property namedescriptiontypedefault value
sizespacing sizestring | enummedium
align-itemsalignmentenumnormal
directionarrangement directionenumrow
wrapWhether to automatically wrapbooleanfalse
fillwhether to fill the entire linebooleanfalse

space slots

Slot NameDescription
defaultdefault slot

Released under the ISC License.