生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

Grid ​

Layout component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="grid": root · item

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-grid>
Vue componentsXhGridItem XhGridRoot
State machineNone: connect computes attributes from props directly
Skin@xihan-ui/styles/grid.css

Props ​

PropTypeRequired
alignGridAlign
colsGridCols
columnGapGridGap
gapGridGap
justifyItemsGridJustifyItems
minColWidthGridMinColWidth
rowGapGridGap
rowsGridRowCount
ruledboolean

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhGridItemspanGridColumnCount | string | GridSpanByBreakpoint
XhGridItemoffsetGridColumnOffset | string | GridOffsetByBreakpoint
XhGridItemrowSpanGridRowCount | string | GridRowSpanByBreakpoint

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
getRootProps() => T['element']
getItemProps(props?: GridItemProps) => T['element']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

No keyboard interaction: the component takes no focus, or focus behavior comes entirely from native elements.

Style reference ​

Skin ​

@xihan-ui/styles/grid.css is written against [data-scope="grid"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-grid in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-alignprops.align
rootdata-colscols.base
rootdata-cols-lgcols.lg
rootdata-cols-mdcols.md
rootdata-cols-smcols.sm
rootdata-cols-xlcols.xl
rootdata-column-gapprops.columnGap
rootdata-gapprops.gap
rootdata-justify-itemsprops.justifyItems
rootdata-min-colprops.minColWidth
rootdata-row-gapprops.rowGap
rootdata-rowstier(props.rows, MAX_COLUMN_COUNT)
rootdata-split'' (present only while the condition holds)
itemdata-offsetoffset.base
itemdata-offset-lgoffset.lg
itemdata-offset-mdoffset.md
itemdata-offset-smoffset.sm
itemdata-offset-xloffset.xl
itemdata-row-spanrowSpan.base
itemdata-row-span-lgrowSpan.lg
itemdata-row-span-mdrowSpan.md
itemdata-row-span-smrowSpan.sm
itemdata-row-span-xlrowSpan.xl
itemdata-spanspan.base
itemdata-span-lgspan.lg
itemdata-span-mdspan.md
itemdata-span-smspan.sm
itemdata-span-xlspan.xl

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-grid-column-gaprootcolumn-gapcolumn-gap=lg
column-gap=md
column-gap=sm
column-gap=xl
column-gap=xs
--xh-layout-gap-lg
--xh-layout-gap-md
--xh-layout-gap-sm
--xh-layout-gap-xl
--xh-layout-gap-xs
--xh-grid-columnsrootgrid-template-columnsdefault
min-col
--xh-_grid-col-min
--xh-_grid-cols
--xh-grid-divideritem
root
border
border-block-end
border-inline-end
split--xh-border-default
--xh-grid-gaprootgapdefault
gap=lg
gap=md
gap=sm
gap=xl
gap=xs
--xh-layout-gap-lg
--xh-layout-gap-md
--xh-layout-gap-sm
--xh-layout-gap-xl
--xh-layout-gap-xs
--xh-space-0
--xh-grid-row-gaprootrow-gaprow-gap=lg
row-gap=md
row-gap=sm
row-gap=xl
row-gap=xs
--xh-layout-gap-lg
--xh-layout-gap-md
--xh-layout-gap-sm
--xh-layout-gap-xl
--xh-layout-gap-xs
--xh-grid-rowsrootgrid-template-rowsrows--xh-_grid-rows
--xh-grid-ruled-paddingitem
root
paddingsplit--xh-space-1_5

Released under The MIT License