Skip to content
API 风格:

Space 間隔 ​

子コンポーネント間に統一された間隔を提供するレイアウトコンテナです。ネイティブ CSS gap をベースに実装されています。純粋なレイアウトコンテナ(role="presentation")であり、アクセシビリティツリーには参加しません。

基本的な使い方 ​

水平間隔
vue
<script setup lang="ts">
</script>

<template>
  <LhSpace>
    <LhButton>ボタン 1</LhButton>
    <LhButton>ボタン 2</LhButton>
    <LhButton>ボタン 3</LhButton>
  </LhSpace>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhSpace>
    <LhButton>ボタン 1</LhButton>
    <LhButton>ボタン 2</LhButton>
    <LhButton>ボタン 3</LhButton>
  </LhSpace>
</template>

垂直間隔 ​

垂直間隔
vue
<script setup lang="ts">
</script>

<template>
  <LhSpace direction="vertical">
    <LhButton>ボタン 1</LhButton>
    <LhButton>ボタン 2</LhButton>
  </LhSpace>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhSpace direction="vertical">
    <LhButton>ボタン 1</LhButton>
    <LhButton>ボタン 2</LhButton>
  </LhSpace>
</template>

間隔サイズ ​

3 段階のプリセットが --lh-spacing-* テーマトークンにマッピングされます。ピクセル数値や [水平, 垂直] 配列もサポートします。

間隔サイズ
vue
<script setup lang="ts">
</script>

<template>
  <!-- small プリセット段階 -->
  <LhSpace size="small">
    <LhButton>small</LhButton>
    <LhButton>small</LhButton>
  </LhSpace>
  <!-- medium プリセット段階 -->
  <LhSpace size="medium">
    <LhButton>medium</LhButton>
    <LhButton>medium</LhButton>
  </LhSpace>
  <!-- large プリセット段階 -->
  <LhSpace size="large">
    <LhButton>large</LhButton>
    <LhButton>large</LhButton>
  </LhSpace>
  <!-- カスタムピクセル 8 -->
  <LhSpace :size="8">
    <LhButton>8px</LhButton>
    <LhButton>8px</LhButton>
  </LhSpace>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- small プリセット段階 -->
  <LhSpace size="small">
    <LhButton>small</LhButton>
    <LhButton>small</LhButton>
  </LhSpace>
  <!-- medium プリセット段階 -->
  <LhSpace size="medium">
    <LhButton>medium</LhButton>
    <LhButton>medium</LhButton>
  </LhSpace>
  <!-- large プリセット段階 -->
  <LhSpace size="large">
    <LhButton>large</LhButton>
    <LhButton>large</LhButton>
  </LhSpace>
  <!-- カスタムピクセル 8 -->
  <LhSpace :size="8">
    <LhButton>8px</LhButton>
    <LhButton>8px</LhButton>
  </LhSpace>
</template>

折り返しと整列 ​

折り返し

alignment が子項目の整列方法を制御します。デフォルトは中央揃えで、先頭揃えや末尾揃えに切り替えられます。

整列方法
vue
<script setup lang="ts">
</script>

<template>
  <!-- 折り返しを許可 -->
  <LhSpace wrap>
    <LhTag v-for="n in 12" :key="n">タグ {{ n }}</LhTag>
  </LhSpace>
  <!-- start 揃え -->
  <LhSpace alignment="start">
    <LhButton>start 揃え</LhButton>
    <span style="height: 48px; line-height: 48px">高いコンテンツ</span>
  </LhSpace>
  <!-- end 揃え -->
  <LhSpace alignment="end">
    <LhButton>end 揃え</LhButton>
    <span style="height: 48px; line-height: 48px">高いコンテンツ</span>
  </LhSpace>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- 折り返しを許可 -->
  <LhSpace wrap>
    <LhTag v-for="n in 12" :key="n">タグ {{ n }}</LhTag>
  </LhSpace>
  <!-- start 揃え -->
  <LhSpace alignment="start">
    <LhButton>start 揃え</LhButton>
    <span style="height: 48px; line-height: 48px">高いコンテンツ</span>
  </LhSpace>
  <!-- end 揃え -->
  <LhSpace alignment="end">
    <LhButton>end 揃え</LhButton>
    <span style="height: 48px; line-height: 48px">高いコンテンツ</span>
  </LhSpace>
</template>

Space API ​

Props ​

プロパティ名説明型デフォルト値
direction並び方向"horizontal" | "vertical"'horizontal'
size間隔:プリセット段階 / ピクセル数値 / [水平, 垂直]number | "small" | "medium" | "large" | [number, number]'medium'
wrap折り返しを許可するか(水平方向のみ)booleantrue
alignment整列方法"start" | "center" | "end" | "baseline"'start'
sxクイックレイアウトプロパティ({ mt: 2 } など)。インラインスタイルにマージされ、alignment より優先されるLhSxProps—

アクセシビリティ ​

  • コンテナは role="presentation" の純粋なレイアウト要素で、フォーカスを妨げない
  • 間隔はネイティブ CSS gap に基づき、DOM で子要素をラップしない

型定義 ​

本コンポーネントが外部にエクスポートする TypeScript 型構造は以下のとおりです(packages/components/space/src/types.ts および @lh-ui/share/core/* ソースから自動抽出。各エントリをクリックすると完全な定義を確認できます。プロパティの説明は上記の Props 表を参照してください):

LhSpaceProps
ts
export interface LhSpaceProps {
  /** 並び方向 */
  direction?: 'horizontal' | 'vertical'
  /** 間隔:プリセット段階 / ピクセル数値 / [水平, 垂直] */
  size?: LhSpaceSizeInput
  /** 折り返しを許可するか(水平方向のみ) */
  wrap?: boolean
  /** 整列方法 */
  alignment?: LhSpaceAlignment
  /** sx クイックレイアウトプロパティ */
  sx?: LhSxProps
}
LhSpaceSizeInput (@lh-ui/share/core/space から)
ts
/**
 * 正規化された間隔:プリセット段階は spacing トークンにマッピングされ、数値は px として扱われる
 */
export type LhSpaceSizeInput = 'small' | 'medium' | 'large' | number | [number, number]
LhSpaceAlignment (@lh-ui/share/core/space から)
ts
/** 間隔の整列方法 */
export type LhSpaceAlignment = 'start' | 'center' | 'end' | 'baseline'

国風の美で、コードの基を築く