Skip to content

Common Card Properties

LCARdS share a set of common top-level configuration properties regardless of card type. This page documents them alongside how sizing interacts with the HA grid system.

Common Properties

PropertyTypeDescription
idstringCustom card ID for Rules Engine targeting (e.g. my-light-btn)
tagslistOne or more string tags for Rules Engine group targeting (e.g. [nav, lights])
heightstringCSS height override applied to the card host element (see below)
widthstringCSS width override applied to the card host element (see below)
grid_optionsobjectHA grid sizing — rows and columns for the Lovelace grid (see below)
data_sourcesobjectDataSource definitions — see DataSources

Card Identification (id and tags)

id and tags are used by the Rules Engine to target cards for conditional style patches.

yaml
type: custom:lcards-button
id: kitchen-light-btn        # unique identifier — target with rules selector `#kitchen-light-btn`
tags:
  - kitchen
  - lights
  - nav
  • id targets a single specific card (#kitchen-light-btn)
  • tags target groups of cards (.lights, .nav)
  • Neither field affects visual appearance directly — they exist solely for rules targeting

Sizing (height and width)

These properties set an explicit CSS size on the card's host element, overriding whatever the container would normally assign.

Accepted formats

ValueResultExample
Bare integerTreated as pixels200200px
px valueExact pixels200px
vh / vwViewport-relative50vh
%Percentage of container100%
em / remFont-relative10em
yaml
type: custom:lcards-button
height: 200          # 200px
width: 500px
yaml
type: custom:lcards-button
height: 50vh         # half viewport height
width: 100%          # fill container

When to use this

These overrides are most useful when a card's natural size would be wrong or unpredictable:

  • Alert overlays — cards used as overlay content need an explicit size because the overlay container uses height: auto
  • Horizontal stacks — when you need cards to fill remaining space (width: 100%)
  • Fixed-size panels — embedding a chart or MSD at a specific pixel height
  • Aspect-ratio layouts — pairing with width to keep proportions consistent

Note on getCardSize(): HA uses getCardSize() to pre-allocate grid space before the card renders. When height is set in pixels, LCARdS uses that value to report grid rows (px ÷ 56, rounded up). For non-px units (vh, %, etc.) the card falls back to its default row count since the pixel value cannot be determined at configuration time.


HA Grid Sizing (grid_options)

grid_options controls how the card occupies the Lovelace grid. This is the standard HA mechanism and is independent of height/width.

yaml
type: custom:lcards-button
grid_options:
  columns: 6    # span 6 grid columns (out of 12)
  rows: 2       # request 2 grid rows of height
FieldTypeDescription
columnsnumberGrid columns to span (HA grid is 12 columns wide)
rowsnumberGrid rows to request

height/width vs grid_options

These two systems operate independently and serve different purposes:

height / widthgrid_options
What it setsCSS size of the card host elementHA grid slot allocation
Effect on layoutHow large the card renders inside its slotHow large a slot HA reserves in the grid
Typical useOverlays, stacks, fixed-px sizingStandard dashboard grid layout
UnitsAny CSS unit or bare integer (= px)Whole numbers only

In most dashboard layouts you only need grid_options. Use height/width when you need to override the rendered size independently of the grid slot — for example when a card is inside a fixed-size container that doesn't use the HA grid.