Before After
Appearance
Appearance
import Spacer from '@ui/Spacer.vue'Add a 16px gap between adjacent items.
<Alert green">A</Alert>
<Alert red">B</Alert><Alert green">A</Alert>
<Spacer/>
<Alert red">B</Alert><Layout flex>
<Alert blue">A</Alert>
<Alert yellow">B</Alert>
<Spacer/>
<Alert red">C</Alert>
</Layout><script setup>
const size = ref(1);
</script>
<template>
<Input v-model="size" type="range" />
<Alert yellow>A</Alert>
<Spacer :size="+size" />
<Alert purple>B</Alert>
</template>Note the + before size. Some browsers will output a string for the Input value, and the JavaScript + prefix parses it into a number. Spacers need numeric size values because positive size values affect the dimensions of the element while negative sizes cause negative margins.
<Layout stack no-gap
:style="{ height: size + '%' }"
>
<Button min-content outline>A</Button>
<Spacer grow title="grow" />
<Button min-content outline>B</Button>
<Button min-content outline>C</Button>
<Spacer shrink title="shrink" />
<Button min-content outline>D</Button>
<Spacer grow shrink title="grow shrink" />
<Button min-content outline>E</Button>
</Layout>v and h props By default, a spacer is square. You can make it horizontal with h and vertical with v. See the example in the following section.
<Input v-model="size" type="range" />
<Card min-content title="h">
<Spacer h :size="size * 4" style="border:5px dashed;" />
</Card>
<Card min-content title="v">
<Spacer v :size="size * 4" style="border:5px dashed;" />
</Card>