From c6c4f91b0e6ec2853375b82d9bab1b1717cb4c29 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 15 Sep 2025 10:29:48 +0200 Subject: [PATCH] Use slot for tile card info (#27046) --- src/components/tile/ha-tile-info.ts | 18 ++++++++++-------- src/panels/lovelace/cards/hui-tile-card.ts | 11 ++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/tile/ha-tile-info.ts b/src/components/tile/ha-tile-info.ts index df8b7e4db7..8168badeba 100644 --- a/src/components/tile/ha-tile-info.ts +++ b/src/components/tile/ha-tile-info.ts @@ -1,20 +1,21 @@ -import type { TemplateResult } from "lit"; -import { html, css, LitElement, nothing } from "lit"; +import { css, html, LitElement } from "lit"; import { customElement, property } from "lit/decorators"; @customElement("ha-tile-info") export class HaTileInfo extends LitElement { @property() public primary?: string; - @property() public secondary?: string | TemplateResult<1>; + @property() public secondary?: string; protected render() { return html`
- ${this.primary} - ${this.secondary - ? html`${this.secondary}` - : nothing} + + ${this.primary} + + + ${this.secondary} +
`; } @@ -27,7 +28,8 @@ export class HaTileInfo extends LitElement { align-items: flex-start; justify-content: center; } - span { + span, + ::slotted(*) { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; diff --git a/src/panels/lovelace/cards/hui-tile-card.ts b/src/panels/lovelace/cards/hui-tile-card.ts index 5d3c33a019..2083fb0a28 100644 --- a/src/panels/lovelace/cards/hui-tile-card.ts +++ b/src/panels/lovelace/cards/hui-tile-card.ts @@ -325,11 +325,12 @@ export class HuiTileCard extends LitElement implements LovelaceCard { > ${renderTileBadge(stateObj, this.hass)} - + + ${name} + ${stateDisplay + ? html`${stateDisplay}` + : nothing} + ${features.length > 0 ? html`