Skip to content
API 风格:

Grid ​

A 24-column grid implemented with CSS Grid (grid-template-columns: repeat(24, 1fr)); span / offset map straight onto grid-column.

Basic usage ​

Basic
span 12
span 12
span 8
span 8
span 8
vue
<script setup lang="ts">
</script>

<template>
  <LhRow :gutter="12">
    <!-- span 12 -->
    <LhCol :span="12">span 12</LhCol>
    <!-- span 12 -->
    <LhCol :span="12">span 12</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
  </LhRow>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhRow :gutter="12">
    <!-- span 12 -->
    <LhCol :span="12">span 12</LhCol>
    <!-- span 12 -->
    <LhCol :span="12">span 12</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
  </LhRow>
</template>

Offset and alignment ​

Offset / align
offset 3
centered
vue
<script setup lang="ts">
</script>

<template>
  <LhRow justify="center" align="middle" :gutter="12">
    <LhCol :span="6" :offset="3">offset 3</LhCol>
    <LhCol :span="6">centered</LhCol>
  </LhRow>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhRow justify="center" align="middle" :gutter="12">
    <LhCol :span="6" :offset="3">offset 3</LhCol>
    <LhCol :span="6">centered</LhCol>
  </LhRow>
</template>

Wrap ​

Set wrap to false to force all columns onto a single line (combine with overflow for a horizontally scrolling grid).

No wrap
span 8
span 8
span 8
span 8
vue
<script setup lang="ts">
</script>

<template>
  <!-- No wrap -->
  <LhRow :wrap="false" :gutter="12">
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
  </LhRow>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- No wrap -->
  <LhRow :wrap="false" :gutter="12">
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
    <!-- span 8 -->
    <LhCol :span="8">span 8</LhCol>
  </LhRow>
</template>

Responsive breakpoints ​

Declare sizes per breakpoint with xs / sm / md / lg / xl (Tailwind thresholds: 640 / 768 / 1024 / 1280); undeclared tiers fall back downward (xs is the catch-all), and span is used when no breakpoint is set. Resize the browser window to observe.

Responsive
span 24 / md 12 / xl 8
span 24 / md 12 / xl 8
span 24 / xl 8
vue
<script setup lang="ts">
</script>

<template>
  <LhRow :gutter="12">
    <LhCol :span="24" :md="12" :xl="8">span 24 / md 12 / xl 8</LhCol>
    <LhCol :span="24" :md="12" :xl="8">span 24 / md 12 / xl 8</LhCol>
    <LhCol :span="24" :xl="8">span 24 / xl 8</LhCol>
  </LhRow>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhRow :gutter="12">
    <LhCol :span="24" :md="12" :xl="8">span 24 / md 12 / xl 8</LhCol>
    <LhCol :span="24" :md="12" :xl="8">span 24 / md 12 / xl 8</LhCol>
    <LhCol :span="24" :xl="8">span 24 / xl 8</LhCol>
  </LhRow>
</template>

Push / pull ​

push / pull shift the start line right / left on top of offset, for fine-grained column alignment.

Push / pull
span 8 push 8
span 8
vue
<script setup lang="ts">
</script>

<template>
  <LhRow :gutter="12">
    <LhCol :span="8" :push="8">span 8 push 8</LhCol>
    <LhCol :span="8">span 8</LhCol>
  </LhRow>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhRow :gutter="12">
    <LhCol :span="8" :push="8">span 8 push 8</LhCol>
    <LhCol :span="8">span 8</LhCol>
  </LhRow>
</template>

Pull and responsive breakpoints ​

pull moves a column left by the given number of columns (opposite of offset); xs / sm / md / lg / xl declare span per breakpoint, and sizes declares them all at once.

pull / breakpoints
pull 2
Responsive
sizes
vue
<script setup lang="ts">
</script>

<template>
  <LhRow :gutter="12">
    <LhCol :span="8" :pull="2">pull 2</LhCol>
    <LhCol :span="12" :xs="24" :sm="12" :lg="8">Responsive</LhCol>
    <LhCol :span="10" :sizes="{ xs: 24, md: 12, xl: 6 }">sizes</LhCol>
  </LhRow>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhRow :gutter="12">
    <LhCol :span="8" :pull="2">pull 2</LhCol>
    <LhCol :span="12" :xs="24" :sm="12" :lg="8">Responsive</LhCol>
    <LhCol :span="10" :sizes="{ xs: 24, md: 12, xl: 6 }">sizes</LhCol>
  </LhRow>
</template>

API ​

LhRow Props ​

AttributeDescriptionTypeDefault
justifyMain-axis distribution'start' | 'center' | 'end' | 'space-between' | 'space-around''start'
alignCross-axis alignment'top' | 'middle' | 'bottom''top'
gutterColumn gap (px or [horizontal, vertical])number | [number, number]0
wrapWrap columnsbooleantrue
sxQuick layout propsLhSxProps—

LhCol Props ​

AttributeDescriptionTypeDefault
spanColumns to occupy (24-column grid)number—
offsetColumns to offset from the leftnumber—
pushColumns to push rightnumber—
pullColumns to pull leftnumber—
xsBelow 640px (falls back downward)LhColSize—
sm640px and upLhColSize—
md768px and upLhColSize—
lg1024px and upLhColSize—
xl1280px and upLhColSize—
sizesPer-breakpoint declaration (equivalent to xs~xl)Partial<Record<LhGridBreakpoint, LhColSize>>—
sxQuick layout propsLhSxProps—

Accessibility ​

  • Layout-only component with no interactive semantics; use List / Table for semantic structures.

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/grid/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhRowJustify
ts
export type LhRowJustify = 'start' | 'center' | 'end' | 'space-between' | 'space-around'
LhRowAlign
ts
export type LhRowAlign = 'top' | 'middle' | 'bottom'
LhRowProps
ts
export interface LhRowProps {
  justify?: LhRowJustify
  align?: LhRowAlign
  gutter?: number | [number, number]
  wrap?: boolean
  sx?: LhSxProps
}
LhColProps
ts
export interface LhColProps {
  span?: number
  offset?: number
  push?: number
  pull?: number
  xs?: LhColSize
  sm?: LhColSize
  md?: LhColSize
  lg?: LhColSize
  xl?: LhColSize
  sizes?: LhBreakpointSizes
  sx?: LhSxProps
}
LhColSize (from @lh-ui/share/core/grid)
ts
export type LhColSize = number | LhGridSpan
LhGridSpan (from @lh-ui/share/core/grid)
ts
export interface LhGridSpan {
  span?: number
  offset?: number
  push?: number
  pull?: number
}
LhBreakpointSizes (from @lh-ui/share/core/grid)
ts
export type LhBreakpointSizes = Partial<Record<LhGridBreakpoint, LhColSize>>
LhGridBreakpoint (from @lh-ui/share/core/grid)
ts
export type LhGridBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl'

Constants ​

Public constants used by this component (linked from the Type / Default columns in the Props table above):

LH_GRID_COLUMNS (from @lh-ui/share/core/grid)
ts
export const LH_GRID_COLUMNS = 24
LH_GRID_BREAKPOINTS (from @lh-ui/share/core/grid)
ts
export const LH_GRID_BREAKPOINTS: Record<LhGridBreakpoint, number> = {
  xs: 0,
  sm: 640,
  md: 768,
  lg: 1024,
  xl: 1280,
}
LH_GRID_BREAKPOINT_ORDER (from @lh-ui/share/core/grid)
ts
export const LH_GRID_BREAKPOINT_ORDER: LhGridBreakpoint[] = ['xl', 'lg', 'md', 'sm', 'xs']

Beauty of tradition, foundation of code