Skip to content

Space ​

Used to lay out the spacing between adjacent elements, replacing hand-written margin. The spacing relies entirely on CSS gap, which both targets support natively.

Basic usage ​

vue
<template>
  <lh-space>
    <lh-tag>水墨</lh-tag>
    <lh-tag>留白</lh-tag>
    <lh-tag>国风</lh-tag>
  </lh-space>
</template>

Direction ​

vue
<template>
  <lh-space direction="vertical">
    <lh-tag>水墨</lh-tag>
    <lh-tag>留白</lh-tag>
  </lh-space>
</template>

Spacing steps ​

The preset steps reference spacing tokens (customizable via --lh-spacing-*); numbers are treated as px; an array controls the horizontal and vertical spacing separately.

vue
<template>
  <lh-space size="small">
    <lh-tag>Small</lh-tag>
    <lh-tag>Small</lh-tag>
  </lh-space>
  <lh-space size="medium">
    <lh-tag>Medium</lh-tag>
    <lh-tag>Medium</lh-tag>
  </lh-space>
  <lh-space size="large">
    <lh-tag>Large</lh-tag>
    <lh-tag>Large</lh-tag>
  </lh-space>
  <lh-space :size="24">
    <lh-tag>24px</lh-tag>
    <lh-tag>24px</lh-tag>
  </lh-space>
  <lh-space :size="[8, 16]">
    <lh-tag>Horizontal 8</lh-tag>
    <lh-tag>Vertical 16</lh-tag>
  </lh-space>
</template>

Alignment and wrapping ​

vue
<template>
  <lh-space alignment="center">
    <lh-tag>Centered</lh-tag>
    <lh-button type="primary" size="small">Button</lh-button>
  </lh-space>
  <lh-space :wrap="true">
    <lh-tag v-for="i in 20" :key="i">Tag {{ i }}</lh-tag>
  </lh-space>
</template>

Wrapping only takes effect in the horizontal direction

wrap is only meaningful for direction="horizontal"; passing it in the vertical direction is ignored.

Props ​

PropDescriptionTypeDefault
directionArrangement direction'horizontal' | 'vertical''horizontal'
sizeSpacing: a preset step / a pixel number / [horizontal, vertical]'small' | 'medium' | 'large' | number | [number, number]'medium'
wrapWhether wrapping is allowed (horizontal direction only)booleantrue
alignmentAlignment'start' | 'center' | 'end' | 'baseline''start'
customClassCustom class namestring—
sxQuick layout propsLhSxProps—

Slots ​

SlotDescription
defaultThe children whose spacing is being arranged