You are reading the development docs (2026.12.1-dev.1): features here may not be released yet.
Skip to content

Layout View ​

custom:lcards-layout-view

The layout view is a dashboard view type that lays the whole view out as one CSS grid, which you build and edit in place on the dashboard. Drag track sizes, draw named areas and drop cards into them, the way Home Assistant's sections view works, for LCARS layouts where every panel has its place.

  • It reads the same layout and view_layout keys as lovelace-layout-card's custom:grid-layout, so a grid-layout view usually moves over by changing only its type; see Compatibility with grid-layout.
  • The live examples on this page draw the view's grid with the Layout Card, which shares its layout code, in a box 320 px tall. On a dashboard the view fills the screen below the header.

Try it

Add a blank layout view (below), open the dashboard's edit mode and build the grid in place: no YAML needed.

Quick Start ​

A layout view is one entry under views: in the dashboard's raw configuration (Edit dashboard, then Raw configuration editor). The examples on this page show that one entry; it goes in the views: list with a dash in front.

  • With no layout the view is a blank 3 by 3 grid: open edit mode and build it there.
  • With layout, name the areas in grid-template-areas and place each card in one with view_layout.grid-area.
yaml
# A header, a sidebar and a content area
type: custom:lcards-layout-view
title: Bridge
layout:
  grid-template-columns: 160px 1fr
  grid-template-rows: 60px 1fr
  grid-template-areas: |
    "header header"
    "sidebar content"
  grid-gap: 8px
cards:
  - type: custom:lcards-elbow
    elbow:
      type: header-left
      segment:
        color: var(--lcards-orange)
    view_layout:
      grid-area: header
  - type: custom:lcards-button
    preset: lozenge
    text:
      name:
        content: SIDEBAR
        show: true
    view_layout:
      grid-area: sidebar
  - type: custom:lcards-button
    preset: outline
    text:
      name:
        content: CONTENT
        show: true
    view_layout:
      grid-area: content
yaml
# A blank view: build it in edit mode
views:
  - title: New Layout
    type: custom:lcards-layout-view

Editing in the dashboard ​

In the dashboard's edit mode a toolbar above the grid switches between Layout mode (the grid) and Card mode (the cards in it). The toolbar sits in its own space, so it never covers your cards.

  • While editing, cards don't run their tap actions: a click selects or edits a card. Home Assistant's Undo button in the dashboard toolbar undoes every change.
  • The ⓘ button at the right end of the toolbar shows tips for the current mode.

Layout mode (the grid) ​

Layout mode shapes the grid itself: tracks, areas and their settings. Column and row headers sit in a gutter above and left of the grid, showing each track's size, and each area is drawn as a coloured outline with its name, so the real cards stay visible.

  • Settings open in a side panel on the right (a sheet at the bottom on a phone); the grid narrows while it is open, so the panel never covers a card.
  • Drag the line between two columns or rows to resize them, and drag a header to reorder. Click a header for its size presets (1fr, auto, 200px, 50%, ...), Insert left/right (or above/below) and Delete.
  • Click an empty cell (or drag across empty cells) to create an area, and click an area to select it: drag its edge grips to resize it or its name to move it. Red cells mean another area is in the way.
More about Layout mode
  • Add tracks: the toolbar's Column and Row buttons add one at the end; Insert in a track's settings adds one next to it.
  • Area menu: each area's ⋮ button has Rename, Add card, Area settings (its per-area settings) and Delete area.
  • Grid settings: the toolbar's tune button sets grid-gap, height, card_margin and padding.
  • Area tint: the toolbar slider sets how strongly areas are coloured: raise it when an area's colour is close to its cards, lower it to see the cards and backgrounds as they are. It starts at 60% and is kept per browser.

Card mode ​

Card mode places and edits the cards inside the areas, with the same controls as Home Assistant's own views. Hover or tap a card and click it to open Home Assistant's card editor.

  • Every empty area shows an Add card tile that opens Home Assistant's card picker; the new card goes in that area.
  • Each card's ⋮ button has Edit, Placement & spacing (per-card placement in the side panel) and Delete; Home Assistant's Undo toast can bring a deleted card back.
  • When several cards share an area (a frame elbow behind an MSD, say), the area shows a picker with one button per card: pick one to bring its controls to the front.
More about cards in one area
  • Layered, not listed: cards in the same area are drawn on top of each other, which suits a frame elbow behind another card. To lay cards out one after another in an area, put a vertical-stack or horizontal-stack card there, or a nested Layout Card.

Layout properties ​

layout holds the grid itself, in CSS Grid's own property names: the column and row tracks, the named areas and the gap between cells. Set only what you need; a view with no layout is 3 by 3.

  • grid-template-areas names the cells: one quoted string per row, one name per column, and . for a cell with no area. A name repeated across neighbouring cells makes one larger area.
  • Track sizes take any CSS value: 1fr shares the free space, auto fits the content, and px, % and vh are fixed.
  • A button, elbow or slider placed straight in a cell of a fixed height fills that cell even when it is shorter than the button's usual 56 px. Fixed means px or vh rows and sizes built from them (clamp(25px, 5vh, 95px)), or fr rows and minmax(40px, 1fr) in a grid with a height. This holds for cards placed by area and for cards placed in order, for rows written with repeat(), inside a layout card that fills a fixed cell, and in a Home Assistant sections card given a number of rows. In an auto or max-content row a card keeps that minimum so it stays visible.
yaml
# Three columns, the middle one twice as wide; a button-high top row
type: custom:lcards-layout-view
layout:
  grid-template-columns: 1fr 2fr 1fr
  grid-template-rows: 56px 1fr
  grid-template-areas: |
    "bar bar bar"
    "left middle right"
  grid-gap: 6px
  padding: 4px
cards:
  - type: custom:lcards-button
    preset: lozenge
    text:
      name:
        content: OPERATIONS
        show: true
    view_layout:
      grid-area: bar
  - type: custom:lcards-button
    preset: outline
    view_layout:
      grid-area: left
  - type: custom:lcards-button
    preset: outline
    view_layout:
      grid-area: middle
  - type: custom:lcards-button
    preset: outline
    view_layout:
      grid-area: right
More about layout
  • Grid-wide gap: grid-gap is the same between every pair of cells; CSS grid has no gap per cell. Use a card's view_layout.margin or an area's margin to space one card.
  • Passed through: place-items, place-content, grid-auto-flow, grid-auto-columns and grid-auto-rows go to the grid as they are.
  • Height: with a height other than auto the grid scrolls when its content is taller.
KeyTypeDefaultDescription
layout.grid-template-columnsstring1fr 1fr 1frColumn track sizes, such as 160px 1fr 1fr
layout.grid-template-rowsstring1fr 1fr 1frRow track sizes
layout.grid-template-areasstring-Area names: one quoted string per row
layout.grid-gapstring5pxGap between cells; gap is read too
layout.heightstringcalc(100dvh - var(--header-height, 56px))The grid's height: the screen below the header
layout.marginstring-Space outside the grid
layout.paddingstring-Space inside the grid, round the cells
layout.card_marginstring-Space round every card in its cell
layout.card_overflowstringvisibleOverflow for every card: visible, hidden or auto
layout.place-itemsstring-Passed to the grid as it is; so is place-content
layout.grid-auto-flowstring-Passed to the grid as it is; so are grid-auto-columns and grid-auto-rows
layout.mediaqueryobject-Grid changes for a screen size; see below
layout.areasobject-Settings per area; see Per-area settings

Responsive layouts (mediaquery) ​

mediaquery changes the grid for a screen size: a different set of columns, rows, areas or gap while a CSS media query matches. Use it to stack the areas in one column on a phone.

  • Each key is a media query ("(max-width: 768px)") and its value the grid keys to use while it matches. When several match, the later ones win.
  • Cards keep their grid-area, so name the same areas in every arrangement.
yaml
# Side by side on a wide screen, stacked below 768 px (narrow your window to see it)
type: custom:lcards-layout-view
layout:
  grid-template-columns: 1fr 1fr
  grid-template-rows: 1fr
  grid-template-areas: |
    "first second"
  grid-gap: 6px
  mediaquery:
    "(max-width: 768px)":
      grid-template-columns: 1fr
      grid-template-rows: 1fr 1fr
      grid-template-areas: |
        "first"
        "second"
cards:
  - type: custom:lcards-button
    preset: outline
    text:
      name:
        content: FIRST
        show: true
    view_layout:
      grid-area: first
  - type: custom:lcards-button
    preset: outline
    text:
      name:
        content: SECOND
        show: true
    view_layout:
      grid-area: second
KeyTypeDefaultDescription
layout.mediaquery.<query>object-While the query matches: grid-template-columns, grid-template-rows, grid-template-areas and grid-gap to use instead

Placing cards (view_layout) ​

Each card's view_layout says where it goes in the grid: usually the name of an area, or grid lines for a card that spans cells without one. A card with no view_layout takes the next free cell.

  • grid-area is the usual way; grid-column and grid-row place a card by line numbers instead (1 / 3 spans the first two columns).
yaml
# By area, and by grid lines
type: custom:lcards-layout-view
layout:
  grid-template-columns: 1fr 1fr 1fr
  grid-template-rows: 1fr 1fr
  grid-template-areas: |
    "top top top"
    ". . ."
cards:
  - type: custom:lcards-button
    preset: outline
    text:
      name:
        content: AREA TOP
        show: true
    view_layout:
      grid-area: top
  - type: custom:lcards-button
    preset: outline
    text:
      name:
        content: LINES 2 TO 4
        show: true
    view_layout:
      grid-column: 2 / 4
      grid-row: "2"
KeyTypeDefaultDescription
view_layout.grid-areastring-The area to place the card in
view_layout.grid-columnstring-Column lines instead of an area, such as 1 / 3
view_layout.grid-rowstring-Row lines instead of an area

Per-card placement ​

place-self, margin, overflow and z-index set how one card sits in its cell. Card mode's Placement & spacing panel writes them.

  • By default a card stretches to fill its cell; place-self: center keeps its own size in the middle instead (a card needs a size of its own for that, such as a height and width).
yaml
# A smaller card centred in its area, with a margin round another
type: custom:lcards-layout-view
layout:
  grid-template-columns: 1fr 1fr
  grid-template-rows: 1fr
  grid-template-areas: |
    "left right"
cards:
  - type: custom:lcards-button
    preset: lozenge
    width: 160
    height: 56
    text:
      name:
        content: CENTRED
        show: true
    view_layout:
      grid-area: left
      place-self: center
  - type: custom:lcards-button
    preset: outline
    text:
      name:
        content: MARGIN
        show: true
    view_layout:
      grid-area: right
      margin: 24px
KeyTypeDefaultDescription
view_layout.place-selfstringstretchstretch, start, center or end, both ways; align-self and justify-self set one way
view_layout.marginstringthe area's, else card_marginSpace round the card in its cell
view_layout.overflowstringthe area's, else card_overflowvisible, hidden or auto (scroll)
view_layout.z-indexnumber-Stacking order where cards overlap

Conditional cards ​

Use Home Assistant's own card visibility to show a card only sometimes: open the card's editor and its Visibility tab. It has screen size presets (mobile, tablet, desktop) and state, user, numeric, time, and and or conditions, and follows them live.

  • The layout view has no view_layout.show key: a pasted grid-layout config that uses it ignores it, so move the condition to the Visibility tab. To change the grid itself by screen size, use mediaquery.

Collapsing rows and columns ​

When a card with a Visibility condition is hidden, its row or column collapses to 0 and the fr rows and columns take the space; it comes back when the card shows again. The view keeps its size and only changes shape inside, as an LCARS screen does: use it for a top bar, a sidebar or a navigation column that appears only sometimes.

  • A row collapses when every card that sits in that row alone is hidden; the same goes for columns. A card without a condition keeps its row and column open, and a card that spans several rows (or columns) doesn't hold one of them open: it just gets smaller.
  • Fixed (60px), fr and auto rows and columns all collapse. The grid gap beside a collapsed one stays.
  • A shown Layout Card with a definite layout.height (such as 10vh) sizes its row; any other card leaves the row at its configured size.
  • In edit mode every row and column shows, as Home Assistant shows every card while editing.

The example is plain YAML: Home Assistant decides visibility, and the docs have no dashboard to do it.

yaml
# A top bar row and a navigation column that collapse while their helpers are off;
# the main area grows into the space and the screen keeps its size.
type: custom:lcards-layout-view
layout:
  grid-template-columns: 180px 1fr
  grid-template-rows: 60px 1fr
  grid-template-areas: |
    "top top"
    "nav main"
cards:
  - type: custom:lcards-button
    preset: lozenge
    view_layout:
      grid-area: top
    visibility:
      - condition: state
        entity_id: input_boolean.show_top_bar
        state: "on"
  - type: custom:lcards-button
    preset: lozenge
    view_layout:
      grid-area: nav
    visibility:
      - condition: state
        entity_id: input_boolean.show_navigation
        state: "on"
  - type: custom:lcards-button
    preset: lozenge
    view_layout:
      grid-area: main
More about collapsing
  • Any condition: every Visibility condition type works (state, numeric_state, screen, user, template, and, or, not): the view follows whether Home Assistant hid the card rather than checking the condition itself. The older entity: key in a state condition works too.
  • The screen keeps its size: the fr rows share the view's height (layout.height, by default the screen below the header), so collapsing never makes the view scroll. With layout.height: auto the view grows and shrinks with its content instead.
  • Media queries: the rows and columns of a matching mediaquery entry collapse the same way.

Per-area settings ​

layout.areas styles an area itself, whatever card is in it: a background, a border, and default spacing for its card. An empty area still shows its background, so it can be an LCARS panel on its own, and the styling stays when you swap the card.

  • Settings are per area name; the keys are CSS property names.
  • A card's own view_layout wins over its area's settings, which win over the grid-wide card_margin and card_overflow.
  • The area's backing sits behind the card and takes no taps. For LCARS chrome you can tap (elbows, buttons, frames), place an lcards-elbow or lcards-button card in the area instead.
yaml
# A coloured header panel, a bordered sidebar with an inset card, an empty gradient panel
type: custom:lcards-layout-view
layout:
  grid-template-columns: 160px 1fr
  grid-template-rows: 48px 1fr
  grid-template-areas: |
    "header header"
    "sidebar content"
  grid-gap: 8px
  areas:
    header:
      background: var(--lcards-orange)
      border-radius: var(--ha-border-radius-lg)
    sidebar:
      border-width: 2px
      border-style: solid
      border-color: theme:colors.ui.secondary
      margin: 8px
    content:
      background-image: linear-gradient(135deg, var(--lcards-blue-darkest), transparent)
cards:
  - type: custom:lcards-button
    preset: lozenge
    text:
      name:
        content: INSET
        show: true
    view_layout:
      grid-area: sidebar
More about area settings
  • Portable: layout.areas is an LCARdS addition. custom:grid-layout ignores it, so a config still works there, just without the area surfaces.
  • Images: a background-image can be a url(/local/...) image of your own as well as a gradient.
KeyTypeDefaultDescription
layout.areas.<area>.backgroundstring-Colour, var(...), gradient or theme: token
layout.areas.<area>.background-imagestring-url(...) or a CSS gradient
layout.areas.<area>.background-sizestringcovercover, contain, 100% 100% (stretch) or auto
layout.areas.<area>.background-positionstringcentercenter, top, bottom, left or right
layout.areas.<area>.background-repeatstringno-repeatno-repeat, repeat, repeat-x or repeat-y
layout.areas.<area>.border-widthstring-Border round the area, such as 2px
layout.areas.<area>.border-stylestring-solid, dashed and the other CSS border styles
layout.areas.<area>.border-colorstring-Border colour; takes theme: tokens
layout.areas.<area>.border-radiusstring-Corner rounding
layout.areas.<area>.place-selfstring-Default placement for the area's card
layout.areas.<area>.marginstring-Default space round the area's card
layout.areas.<area>.overflowstring-Default overflow for the area's card
layout.areas.<area>.z-indexnumber-Stacking order of the area's backing

Layout Card ​

The Layout Card (custom:lcards-layout-card) is the card version of the layout view: the same layout, view_layout and areas, in one card. Use it for a grid inside one area of a layout view, or for a grid panel on any dashboard.

Notes & limitations ​

A few things the grid can't do, and what to use instead.

  • One card per area is the usual layout: use a stack card (or a nested Layout Card) to group several in one area.
  • grid-gap is grid-wide: CSS grid has no gap per cell.
  • Per-card conditions use Home Assistant's Visibility, not a view_layout.show key.

Compatibility with grid-layout ​

The layout and view_layout keys are the same as lovelace-layout-card's grid view (custom:grid-layout), so a config moves between the two by changing only its type. Grid templates, gaps, sizes, spacing, mediaquery and view_layout placement behave the same in both.

  • layout.areas is LCARdS only: in custom:grid-layout everything else works and the area surfaces are not drawn. A grid-layout config pasted into LCARdS works fully.
  • view_layout.show is not supported: per-card conditions use Home Assistant's Visibility instead, and a pasted config ignores the key.

Released under the MIT License. | About