Ga naar hoofdinhoud

CnCardGrid

Responsive CSS grid layout for CnObjectCard instances. Auto-fills with minmax(320px, 1fr).

Wraps: NcLoadingIcon, NcEmptyContent, CnObjectCard

Try it​

Loading CnCardGrid playground…

CnCardGrid showing a grid of object cards

Props​

PropTypeDefaultDescription
objectsArray[]Object data array
schemaObjectnullPassed to each CnObjectCard (required only when using the default card template; not needed when providing a custom #card slot)
loadingBooleanfalseLoading state
pillLooksObject{}The referenced records' colour and icon names, by field and id ({ [field]: { [id]: { color, icon } } }), passed to each CnObjectCard for the record layout's pills that declare resolve.
selectableBooleanfalseEnable card selection
cardFieldColumnsObjectnullThe page's columns by key, passed to each CnObjectCard: a fact or a layout part whose field names a column reads through that column's label, formatter and widget, as the table does
clickToViewBooleanfalseBody click on a selectable card emits click (navigation); selection happens via the checkbox only (CnIndexPage wires this from its rowClickToView)
selectedIdsArray[]Currently selected IDs
rowKeyString'id'Unique identifier field
emptyTextString'No items found'
accentOfFunctionnull(object) => { variant, icon?, label? } | null, each default card's accent (see CnObjectCard)

Events​

EventPayloadDescription
click(object, event)Card clicked. The second argument is the native click event, for opening the card in a new tab on a ctrl/cmd/shift click. A middle click emits aux-click instead.
aux-click(object, event)Card middle-clicked, under the same conditions as click. The second argument is the native auxclick event, for opening the card in a new tab.
selectids[]Selection changed

Slots​

SlotScopeDescription
#card\{ object, selected, schema \}Custom card template
#card-actions\{ object \}Card action buttons
#card-badges\{ object \}Card badges
#empty—Custom empty state

Usage​

<CnCardGrid
:objects="contacts"
:schema="schema"
:selectable="true"
:selected-ids="selected"
@click="onCardClick"
@select="onSelect" />

Reference (auto-generated)​

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnCardGrid.vue and update automatically whenever the component changes.

OpenRegister reliance​

heavy: this component cannot work without OpenRegister. 0 direct references, 16 files reached through imports.

Through: CnActionDialog, CnAssignDialog, CnBulkJobProgress, CnCellRenderer, CnFkResolveCell, CnIndexPage.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
objectsarray[]Array of objects to display as cards
schemaobjectnullSchema definition (passed through to CnObjectCard)
loadingbooleanfalseWhether data is loading
selectablebooleanfalseWhether cards can be selected
clickToViewbooleanfalseWhen true, a body click on a selectable card emits click (navigation) and selection happens via the checkbox only — the card-grid counterpart of CnIndexPage's rowClickToView.
selectedIdsarray[]Array of currently selected object IDs
rowKeystring'id'Property name used as unique identifier
cardFieldsArray<string>nullThe property keys each card's facts list shows (manifest key config.cardFields), passed through to CnObjectCard.
cardLayoutobjectnullBoard look: the record layout each card draws (manifest key config.cardLayout), passed through to CnObjectCard layout.
pillLooksobject\{\}The referenced records' colour and icon names, by field and id ({ [field]: { [id]: { color, icon } } }), passed through to CnObjectCard for the record layout's pills that declare resolve.
cardFieldColumnsobjectnullThe page's columns by key, passed through to CnObjectCard.
statusOffuncnullBoard look: (object) =&gt; status for each card's status pill. See CnObjectCard status.
leadingOffuncnullBoard look: (object) =&gt; { initials | icon } for each card's leading element. See CnObjectCard leading.
footerActionOffuncnullBoard look: (object) =&gt; { label, meta? } for each card's footer action. See CnObjectCard footerAction.
accentOffuncnull(object) =&gt; { variant, icon?, label? } for each card's status accent. See CnObjectCard accent.
emptyTextstring() =&gt; t('nextcloud-vue', 'No items found')Text shown when there are no objects

Events​

NamePayloadDescription
clickundefined
select—
aux-clickundefinedEmitted when a navigating card is middle-clicked, for opening it in a new tab (see openRowTarget). Payload: (object, event) — the card's object and the native auxclick event.

Slots​

NameBindingsDescription
empty—
cardobject, selected, schema
card-actionsobject
card-badgesobject

Board look​

Under the board look the grid is repeat(auto-fill, minmax(var(--cn-card-grid-min, 260px), 1fr)) with a var(--cn-card-grid-gap, 16px) gap, theme hooks for both; without it the 320px track stands. cardFields, cardLayout (the record layout, CnObjectCard layout), statusOf, leadingOf and footerActionOf reach each default CnObjectCard.