Skip to content
Latestv1.0.63

Grid ​

Based on CSS Grid, this layout component offers powerful 2D layout capabilities compared to Row/Col Flex layouts.

Basic Usage ​

Set cols to define columns and gap for spacing.

Basic Usage

Column Span ​

Use span to set how many columns a GridItem spans.

Column Span

Offset ​

Use offset to set column offset.

Offset

Different Gaps ​

gap accepts an array [rowGap, colGap] for separate row and column gaps.

Different Gaps

Custom Column Template ​

When cols is a string, it's used directly as CSS grid-template-columns value.

Custom Column Template

Suffix Element ​

Set suffix to pin a GridItem to the end of the row.

Suffix Element

Use in Nuxt ​

Grid fully supports Nuxt 3/4 SSR rendering. The example below demonstrates a product list page using Grid layout with useFetch for async data loading.

Use in Nuxt

SSR Notes:

  • Grid props and inline styles render consistently during SSR.
  • CSS Grid layout is emitted directly on the server and preserved after hydration.
  • Slot content and positioning props such as span, offset, and suffix remain stable in SSR output.

SSR Safety

Grid component has passed complete SSR tests, ensuring consistent rendering between server and client with no Hydration errors.

API ​

Props ​

Grid ​

PropDescriptionTypeDefault
colsColumns count or CSS templatenumber | string12
gapGapnumber | string | [number | string, number | string]0
colGapColumn gap (overrides gap)number | string0
rowGapRow gap (overrides gap)number | string0
collapsedCollapsedbooleanfalse
collapsedRowsCollapsed visible rowsnumber1
justifyItemsHorizontal alignment'start' | 'end' | 'center' | 'stretch'undefined
alignItemsVertical alignment'start' | 'end' | 'center' | 'stretch'undefined
responsiveResponsive breakpoint mode'self' | 'screen'undefined
themeOverridesComponent-level theme variable overridesComponentThemeVarsundefined

Grid Item ​

PropDescriptionTypeDefault
spanColumn spannumber1
offsetColumn offsetnumber0
suffixSuffix element (pinned to row end)booleanfalse
themeOverridesComponent-level theme variable overridesComponentThemeVarsundefined

Events ​

This component does not expose component events.

Slots ​

Grid ​

SlotDescriptionParameters
defaultGrid content-

Grid Item ​

SlotDescriptionParameters
defaultGrid item content-

Expose ​

This component does not expose public instance methods or properties.

Theme Variables ​

Variable NameDescriptionDefault
--yh-grid-gapGrid gap0
--yh-grid-col-gapGrid column gapvar(--yh-grid-gap, 0)
--yh-grid-row-gapGrid row gapvar(--yh-grid-gap, 0)
--yh-grid-item-paddingItem padding0

Type Exports ​

NameDescription
YhGridPropsProps type for YhGrid
YhGridItemPropsProps type for YhGridItem
YhGridSlotsSlots type for YhGrid
YhGridItemSlotsSlots type for YhGridItem
YhGridInstancePublic instance type for YhGrid
YhGridItemInstancePublic instance type for YhGridItem

Released under the MIT License.