Space

Examples

Space

I'm a text
<dv-space>
  I'm a text
  <dv-button>button</dv-button>
</dv-space>
vue

Vertical

I'm a text
<dv-space direction="vertical">
  I'm a text
  <dv-button>button</dv-button>
  <dv-button>button2</dv-button>
</dv-space>
vue

Spacing size


I'm a text
import { ref } from 'vue';

export default {
  setup: () => {
    const options = ['xs', 'sm', 'md', 'lg'].map((s) => ({
      label: s,
      value: s,
    }));
    const size = ref('md');
    return () => (
      <div class="space-y-4">
        <dv-radio-group options={options} v-model={size.value} />
        <br />
        <dv-space direction="vertical" spacing={size.value}>
          I'm a text
          <dv-button>button</dv-button>
          <dv-button>button2</dv-button>
        </dv-space>
      </div>
    );
  },
};
tsx

Align

center
block
start
block
end
block
baseline
block
<template>
  <div
    class="space-align-block"
    v-for="(align) in ['center', 'start', 'end', 'baseline']"
  >
    <dv-space :align="align">
      {{align}}
      <dv-button>button</dv-button>
      <div class="mock-block">block</div>
    </dv-space>
  </div>
</template>
<style scoped>
  .space-align-block {
    flex: none;
    margin: 8px 4px;
    padding: 4px;
    border: 1px solid #40a9ff;
  }
  .mock-block {
    display: inline-block;
    padding: 32px 8px 16px;
    background: rgba(150, 150, 150, 0.2);
  }
</style>
vue

Custom spacing

I'm a text
import { ref } from 'vue';

export default {
  setup: () => {
    const size = ref('8px');
    return () => (
      <div class="space-y-4">
        <div>
          <dv-input
            value={size.value}
            onInput={(e) => (size.value = e.target.value)}
          />
        </div>
        <dv-space direction="vertical" spacing={size.value}>
          I'm a text
          <dv-button>button</dv-button>
          <dv-button>button2</dv-button>
        </dv-space>
      </div>
    );
  },
};
tsx

Wrap

<dv-space class="w-64 max-w-full" block wrap :spacing="[12, 4]">
  <dv-button v-for="(i) in Array.from(new Array(20).keys())" :key="i">
    {{i}}
  </dv-button>
</dv-space>
vue

Space

Attributes

namedescriptiontypedefault
alignalignstart, end, center, baseline-
directiondirectionvertical, horizontalhorizontal
wrapitems wrap or notbooleanfalse
blockblock or notbooleanfalse
spacingitems spacingISize, string, numbermd