Grid
Declarative CSS Grid container. Exposes every CSS grid property through typed Vue props — no JS track measurement, no fallback to flexbox. columns, rows, gap, areas, autoFlow and alignment props map directly to the corresponding CSS grid properties.
Structure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<origam-grid>. The root ① is a single element with CSS Grid properties applied via inline custom properties. Items ② are slotted children — any DOM element, without a BEM wrapper.- 1.origam-grid
- Root element. display: grid (or inline-grid when inline=true). All grid properties are applied as inline CSS custom properties computed from props.
- 2(slotted children)
- Grid items — any element placed in the default slot. No BEM wrapping. Use grid-area or span CSS on individual items for advanced placement.
API
Props
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.
- columnsTGridTracks'auto'
- grid-template-columns. Three accepted shapes: number (→ repeat(N, 1fr)), string (verbatim CSS), string[] (joined with space). Default 'auto'.
- rowsTGridTracks'auto'
- grid-template-rows. Same accepted shapes as columns. Default 'auto'.
- Both-axis gap. Accepts a size token ('xs' | 'sm' | 'md' | 'lg' | 'xl'), any CSS length string, or a number (px). columnGap / rowGap override their axis.
- columnGap
- Inline-axis-only gap override. Same accepted shapes as gap.
- Block-axis-only gap override. Same accepted shapes as gap.
- areasstring | ReadonlyArray<string>
- grid-template-areas. Accepts string[] (one entry per row, component adds quotes) or a raw CSS string. Example: ['header header', 'sidebar main'].
- grid-auto-flow. Controls implicit track filling. Values: 'row' | 'column' | 'row dense' | 'column dense'. Default 'row'.
- autoColumnsstring
- grid-auto-columns — sizes for implicit columns. Free-form CSS (e.g. "minmax(0, 1fr)").
- autoRowsstring
- grid-auto-rows — sizes for implicit rows. Free-form CSS.
- align-items (block axis). Values: 'start' | 'end' | 'center' | 'stretch' | 'baseline'. Default 'stretch'.
- justify-items (inline axis). Same values as alignItems. Default 'stretch'.
- alignContent
- align-content — block-axis alignment of the whole grid inside its container when the grid is smaller than the container.
- justifyContent
- justify-content — inline-axis alignment of the whole grid inside its container.
- inlinebooleanfalse
- Toggles display: inline-grid instead of display: grid. Useful for grids that must size to their content.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- tagstring'div'
- HTML element rendered at the root (e.g. "ul", "section").
- heightnumber | string
- Overrides the grid height.
- maxHeightnumber | string
- maxWidthnumber | string
- Maximum grid width.
- minHeightnumber | string
- Minimum grid height.
- minWidthnumber | string
- widthnumber | string
- Overrides the grid width.
- marginboolean | number | string
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- paddingboolean | number | string
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- roundedboolean | number | string | TRounded | null | undefined
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- elevationTElevation
- bgColorTColor
- colorTColor
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
API
Slots
Emplacements de contenu exposés par ce composant.
- #default
- Grid items. Any element placed here participates in the grid layout. Use grid-area or column/row span CSS to position items.
API
Membres exposés
Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Filters and forwards a subset of props.
- ComputedRef<string | undefined>
- Serialised grid-template-columns CSS value computed from the columns prop.
- ComputedRef<string | undefined>
- Serialised grid-template-rows CSS value computed from the rows prop.
- ComputedRef<string | undefined>
- Serialised grid-template-areas CSS value computed from the areas prop.
- ComputedRef<string | undefined>
- Resolved gap value (size token → CSS var reference, or raw CSS value).
- ComputedRef<string | undefined>
- Resolved column-gap value.
- ComputedRef<string | undefined>
- Resolved row-gap value.
Personnalisation
Variables CSS
Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.
- Gap token for size xs.
- Gap token for size sm.
- Gap token for size md (default).
- Gap token for size lg.
- Gap token for size xl.
- Computed grid-template-columns value set from the columns prop.
- Computed grid-template-rows value set from the rows prop.
Inclusion
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Notes
- The tag prop defaults to "div" — change it to a semantic element when the grid represents a meaningful structure (e.g. tag="ul" with list items, tag="section" for a named region).
- CSS Grid visual reordering (via order or explicit grid-row/column placement) can diverge from DOM order. Keyboard navigation follows DOM order — avoid visual arrangements that confuse users navigating by Tab.
Fondation
Design tokens
Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.
- dimensionvar(--origam-space---1)
- Gap size xs (4px).
- dimensionvar(--origam-space---2)
- Gap size sm (8px).
- dimensionvar(--origam-space---4)
- Gap size md / default (16px).
- dimensionvar(--origam-space---6)
- Gap size lg (24px).
- dimensionvar(--origam-space---8)
- Gap size xl (32px).
Interactif
Playground
Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.
Rendu de l’aperçu en cours…
Usage
Exemples
Extraits de code prêts à coller dans vos templates.
N-column grid
Named template areas
Auto-fill responsive columns