Holo Grid
The holo-grid is a layout component designed to arrange children in a clean CSS grid. It features configurable column counts and gap sizes based on the design system’s spacing tokens, and by default collapses to a single column below 768px wide. For layouts that adapt to the space available instead, use fluid columns.
When to use
Section titled “When to use”Use it for:
- Laying out equal-width columns of cards or tiles with a consistent gap (
cols,gap,min-item-width). - Dashboards and galleries where items share a visual weight.
Don’t use it for:
- A single column or row of items. Use Stack.
- Tabular data with rows and columns of related values. Use Table.
- Constraining page width. Use Container.
Live Preview
Section titled “Live Preview”Three-Column Grid (Default)
Section titled “Three-Column Grid (Default)”Below is an interactive live preview of a 3-column layout featuring standard cards.
Vector Grid
A multi-dimensional geometric matrix designed for high-throughput spatial analysis.
Quantum Array
Dynamic quantum entanglement coordinates mapped onto a sub-atomic grid layout.
Holographic Core
Centralized optical beam emitter generating synthetic voxel architectures.
<holo-grid cols="3" gap="md"> <div>Vector Grid</div> <div>Quantum Array</div> <div>Holographic Core</div></holo-grid>Two-Column Grid with Large Gap
Section titled “Two-Column Grid with Large Gap”You can also specify lower or higher column counts, alongside larger or smaller gap spacings:
Flux Capacitor
Regulates electromagnetic flow across temporal interfaces inside the grid.
Chronal Engine
Synchronizes state updates with local spacetime frames of reference.
<holo-grid cols="2" gap="lg"> <div>Flux Capacitor</div> <div>Chronal Engine</div></holo-grid>Fluid columns
Section titled “Fluid columns”Set min-item-width to a CSS length and the grid fits as many columns as its own width allows, from 1 up to cols. It ignores the viewport width, so it also adapts inside a narrow sidebar or on a phone. In fluid mode cols is the maximum number of columns, not a fixed count.
Vector Grid
Quantum Array
Holographic Core
Flux Capacitor
<!-- 2 columns on a 360px phone, 4 columns once the grid is about 620px wide --><holo-grid cols="4" min-item-width="9rem"> <div>Vector Grid</div> <div>Quantum Array</div> <div>Holographic Core</div> <div>Flux Capacitor</div></holo-grid>Choosing a min-item-width:
- Use
remso columns drop out as people increase their text size. - Pick the narrowest width at which your item content still reads well. Values below about
8remcan squeeze content at 320px wide. - Items never exceed the grid’s width, so there is no horizontal scrolling.
- Always include a CSS unit (
9rem, not9). A unitless or invalid value (for examplebanana) disables the column template, so content is no longer kept to the grid’s width.
Accessibility
Section titled “Accessibility”By default the grid is a presentational CSS layout. It renders a slot with no role, no landmark and no focus behaviour, and it does not change the reading order. Screen readers and keyboard users move through children in DOM order.
If the items are really a list (a gallery of cards, a set of results), tell assistive technology so, which lets screen readers announce “list, 6 items”. Pick the first option that fits:
- A native
<ul>with your own CSS grid. The most native answer, if you own the CSS. You give up the grid’s gap tokens and responsive behaviour. <holo-grid list>when you want the grid’s token-based layout. Described below.- List for a vertical, styled list.
Set list and the host gets role="list". Each element child that has no role of its own gets role="listitem", plus a data-holo-grid-item attribute that marks it as managed by the grid. Children added or removed later are kept in sync.
<holo-grid list cols="3"> <div>Vector Grid</div> <div>Quantum Array</div> <div>Holographic Core</div></holo-grid>- Only element children can be list items. Wrap loose text in an element.
style,script,template,linkandmetachildren are skipped.- A child that has, or once rendered gets, a
roleof its own is left alone. This coversholo-list-itemand components such asholo-alertandholo-spinnerthat keep theiralertorstatusrole. The grid waits for registered custom elements to render before deciding. A hyphenated tag that is not registered, such as an Angular component host, is marked straight away; if it registers later and renders its own role, the grid hands it back. - A non-Stencil element (vanilla, Lit, FAST) that sets its own role in its constructor or
connectedCallbackis only handled if it is registered before the grid marks it. Register such components first, or give them an explicitrolein markup. - A child with its own role other than
listitemmakes the list invalid (a list may only contain list items). Wrap such content in a<div>so the wrapper is the list item. - A
display: contentswrapper becomes the single list item; its children are not separate items. - A role you set on the grid itself is not removed. To keep your own
role="list"through togglinglist, set it before enablinglistor before the grid connects; arole="list"written after the grid wrote its own is treated as the grid’s. If the role is anything other thanlist(includingnoneandpresentation), the grid does not mark its children, since they would have no list parent. - Do not remove
roleordata-holo-grid-itemfrom children yourself; the grid owns them. If a framework managesroleon the same child, give the child its ownroleinstead. - Links and buttons inside items keep their own semantics and keyboard behaviour. Items are not focusable.
- Do not use
listfor grids of form controls or toolbars. Those need their own patterns. - Without
list, the grid writes no attributes. You can still addrole="list"androle="listitem"yourself.
Nesting lists
Section titled “Nesting lists”Put the inner holo-grid list inside a wrapper element, which becomes the outer list item. A nested grid placed directly in another list grid keeps its own list role and is not marked as an item, which leaves the outer list invalid. Direct nesting is unsupported, including toggling the inner grid’s list off at runtime: the outer grid does not re-mark it. A Stencil app that compiles this library in development mode also logs a console warning for a direct child with role="list"; the published bundles do not.
<holo-grid list cols="2"> <div> Group A <holo-grid list cols="2"> <div>One</div> <div>Two</div> </holo-grid> </div> <div>Group B</div></holo-grid>You provide:
- A DOM order that matches the visual order you want people to read and tab through.
- Real structure for what the grid holds, such as headings, lists or cards. Do not use it to present tabular data.
API Reference
Section titled “API Reference”Importing
import '@philbob/hololink-ui/holo-grid';Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
cols | cols | number | 3 | The number of columns at 768px and wider. In fluid mode (min-item-width set), the maximum
number of columns. |
gap | gap | "lg" | "md" | "sm" | 'md' | The gap size between grid items: "sm" (--s-space-xs, 8px), "md" (--s-space-md, 16px), or
"lg" (--s-space-xl, 32px). |
list | list | boolean | false | Exposes the grid as a list: the host gets role="list" and each element child without a
role of its own gets role="listitem" (and a data-holo-grid-item attribute that marks it
as managed by the grid). Children are kept in sync as they are added and removed.
Skipped: style, script, template, link and meta children, and any child that has or
gets a role of its own once it has rendered (a registered custom element is waited for
first), such as holo-list-item, holo-alert or a nested holo-grid list. A hyphenated tag
that is not registered (an Angular component host, say) is marked straight away, and handed
back to the component if it registers later. A child with its own role other
than listitem makes the list invalid, so give such content a listitem wrapper. To nest a
list, wrap the inner holo-grid list in a <div>. A display: contents wrapper becomes one
item itself; its children are not separate items. Only element children can be list items, so
wrap loose text.
A non-Stencil element (vanilla, Lit, FAST) that sets its own role in its constructor or
connectedCallback is only handled if it is registered before the grid marks it. Register
such components first, or give them an explicit role in markup.
A role you set on the grid is not removed. To keep your own role="list" through toggling
list, set it before enabling list or before the grid connects; one written after the grid
wrote its own is treated as the grid's. If the role is anything other than list (including
none and presentation), the grid does not mark its children, because they would have no
list parent. |
minItemWidth | min-item-width | string | undefined | — | Turns on fluid mode: any CSS length for the minimum width of an item, such as 9rem. The grid
fits as many columns as its own width allows, never more than cols and never fewer than 1.
Prefer rem so columns drop out as text size increases. The value must include a CSS unit
(9rem, not 9); a unitless or otherwise invalid value disables the column template. |
Slots
| Slot | Description |
|---|---|
| (default) | The items to place in the grid. |
CSS custom properties
| Property | Description |
|---|---|
--holo-grid-min-item-width | Minimum item width in fluid mode, set from the min-item-width prop. |