diff --git a/gallery/src/demos/demo-hui-grid-and-stack-card.ts b/gallery/src/demos/demo-hui-grid-and-stack-card.ts index e22b5c20d4..4891d6626e 100644 --- a/gallery/src/demos/demo-hui-grid-and-stack-card.ts +++ b/gallery/src/demos/demo-hui-grid-and-stack-card.ts @@ -143,6 +143,15 @@ const CONFIGS = [ entity: light.kitchen_lights `, }, + { + heading: "Size for single card", + config: ` +- type: grid + cards: + - type: entity + entity: light.kitchen_lights + `, + }, { heading: "Vertical Stack", diff --git a/src/panels/lovelace/cards/hui-grid-card.ts b/src/panels/lovelace/cards/hui-grid-card.ts index 256d889a12..b7880b2f6d 100644 --- a/src/panels/lovelace/cards/hui-grid-card.ts +++ b/src/panels/lovelace/cards/hui-grid-card.ts @@ -25,7 +25,9 @@ class HuiGridCard extends HuiStackCard { if (this.square) { const rowHeight = SQUARE_ROW_HEIGHTS_BY_COLUMNS[this.columns] || 1; return ( - (this._cards.length / this.columns) * rowHeight + + (this._cards.length < this.columns + ? rowHeight + : (this._cards.length / this.columns) * rowHeight) + (this._config.title ? 1 : 0) ); }