lovelace-layout-card: Layout-break doesn't cause a column break in HA 2024.6

My Home Assistant version: 2024.6

Layout-card version v2.4.5

What I am doing: Just updated to 2024.6 (on two different HA instances). The layout-break card no longer creates a column break; all cards appear in a single column. The dashboard is set to Vertical (layout-card).

What I expected to happen: The two or three columns in my dashboards would all continue to render as previously.

What happened instead: All cards appear in a single column.

Minimal steps to reproduce: Upgrade to HA 2024.6 and clear cache.

# The least ammount of code possible to reproduce my error

title: Cameras
path: cameras
theme: ios-light-mode-blue-red-alternative
type: custom:vertical-layout
layout:
  width: 400
  max_width: 1000
  max_cols: 2
badges: []
cards:
  - type: vertical-stack
    cards:
  *   *    *
  - type: custom:layout-break

# End of code

Error messages from the browser console:


By putting an X in the boxes ([X]) below, I indicate that I:

  • Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).
  • Have made sure I am using the latest version of the plugin.
  • Have followed the troubleshooting steps of the “Common Problems” section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.
  • Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 43
  • Comments: 72 (5 by maintainers)

Most upvoted comments

For those migrating to a Sections layout, you can actually adjust the yaml to convert your existing layout-card dashboard to a sections one, despite it warning you that migration is not supported.

First, I recommend backing up your dashboards entirely before you begin (hit edit, then click the ••• and pick “Raw configuration editor,” then copy all into a backup file).

To do this:

  1. Edit your dashboard, then click the Edit pencil on the dashboard itself, then the ••• in the popup, then choose “Edit in YAML”

  2. Change type: custom:vertical-layout to type: sections

  3. Remove badges: []

  4. Add max-columns: 3 (or your preference)

  5. Above the ‘cards’ key, add a couple new lines:

    sections:
      - type: grid
    
  6. Indent the existing ‘cards’ and everthing below it, to line up with the t in ‘type’, so it looks like, for ex:

    sections:
      - type: grid
        cards:
          - type: entities
            entities:
              - entity: light.living_room_lights
              - entity: light.dining_room_light
              ...
    
  7. Now, you can either save it, making all of your cards flow into one column (where you can then drag them around in the UI)… or, you can add the other columns manually, wherever you had a - type: custom:layout-break line.

    In place of the - type: custom:layout-break line, add the following two lines to make a new column, reducing the indentation by two levels to make the things under ‘cards:’ line up properly.

    - type: grid
      cards:
    

    And the remaining cards go underneath the cards: key as with the first column.

    If you don’t want to do this part, you can skip this step and just use the UI to make new columns and drag cards into them.

This made the migration much faster for me, but of course using copy-paste isn’t so bad either if you can’t do this.

Seems to still be the same bug as #288.

It is possible to restore the multi-column layout by editing the YAML of the tab as indicated there:

changed:

type: custom:vertical-layout
layout:
  max_cols: 3

to:

type: custom:layout-card
layout_type: custom:vertical-layout
layout:
  max_cols: 3

and it works again.

BUT… Then, when switching the tab to edit mode, the “Modify” buttons no longer appear and actually editing any card becomes impossible.

I guess the issue still exists with core 2024.6.1 that has been released 12h ago…?

I open a PR to fix the issue: https://github.com/thomasloven/lovelace-layout-card/pull/293

That’s good to know. The main thing holding me back from Sections is that I’ve not been able to figure out how to increase the width of a section (or all sections, doesn’t have to be per-section, though that would be nice as well). Maybe I’m overlooking something obvious? Just that they’re not as wide as they need to be 😦 And if someone knows how to address that, maybe they also know how to adjust the gap between sections? That’d be handy too.

There are several theme variables available for section view. That should fix your theme issues 🙂

  • Max width of a section: ha-view-sections-column-max-width (default: 500px)
  • Min width of a section: ha-view-sections-column-min-width (default: 320px)
  • Horizontal gap between sections: ha-view-sections-column-gap (default: 32px)
  • Vertical gap between sections: ha-view-sections-row-gap (default: 8px)
  • Horizontal gap between cards within a section: ha-section-grid-column-gap (default: 8px)
  • Vertical gap between cards within a section: ha-section-grid-row-gap (default: 8px)

I tried grid layouts and combinations of vertical stacks within horizontal stacks, but nothing reproduced the simplicity and clean function of the layout-break card. Like a lot of others, I eagerly await a fix to this incredibly useful and vital frontend.

I guess the issue still exists with core 2024.6.1 that has been released 12h ago…?

All working with the ha-section-grid-row-… variables, thanks all!

Where do I add the ha-view-sections-… variables in the yaml - to the dashboard raw config? what if I’m not using a theme?

You have to create a theme to add these variables. You can create one with these variables only.

With 2024.6 card are now wrapped with a hui-card so the layout card needs to support that.

I went ahead and copy-pasted my dashboards to the new Drag and Drop dashboard layout, and it works quite well with similar Column concepts.

This spells the end of the road for Layout Card for me, and I expect due to the new layout tools, there will be decreasing need for it in the future. Maybe not time for everyone, but for me it works.

Thanks for all the fish. Cheers.

I have gone back to 2024.5.5 as I have this layout in 95% of my UI … I did stare at the source code for 2 seconds then quickly closed it again … hoping someone with understanding of how it works can fix it …

still waiting on 2024.5 release

I mentioned the --row-height: 66px issue in this comment, and it also affects Mushroom chips.

@Montreal666, so far it doesn’t seem there’s a way to configure that value.

@iptvcld, you can create a custom theme and use in the dashboard, using these variables posted earlier. This will solve all issues, except the vertical spacing you see below short cards.

As a summary, given I also had some hiccups trying to create my own theme as well:

  1. create a yaml file under themes/whatever-you-name-it.yaml, like this (Thin sections is the theme name in this example):
# origin: https://github.com/thomasloven/lovelace-layout-card/issues/291#issuecomment-2156524817
Thin sections:
    ha-view-sections-column-max-width:  500px   #default: 500
    ha-view-sections-column-min-width:  320px   #default: 320
    ha-view-sections-column-gap:        32px    #default: 32
    ha-view-sections-row-gap:           8px     #default: 8
    ha-section-grid-column-gap:         8px     #default: 8
    ha-section-grid-row-gap:            8px     #default: 8
  1. make sure you have something similar to this in your configuration.yaml:
frontend:
  themes: !include_dir_merge_named themes
  1. reboot your instance if you had to change configuration.yaml
  2. if you didn’t reboot, or if you made further changes to the theme, you’ll need to go to Developer Tools > Services and call frontend.reload_themes. That would refresh all themes, without the need for you to press F5 on the pages. Don’t forget to select the theme in the Dashboard, Tab or Card. @Montreal666, that’s probably what you missed that made the theme change not reflect in the UI.

Good luck!

Here a build (on macOS) of layout-card.js (gzipped for github): layout-card.js.gz

I copied/pasted everything into a Sections dashboard. I set up my 3 columns as before, but I’m missing the width element that I used for a 7’ tablet, I had:

width: 320
max_cols: 3
card_margin: 1px 7px 6px

Now I’m getting only 2 columns with the 3rd appearing under the first. On my desktop I see 3 columns. Is there a way to use percentages or something for this new Sections view?

That’s good to know. The main thing holding me back from Sections is that I’ve not been able to figure out how to increase the width of a section (or all sections, doesn’t have to be per-section, though that would be nice as well). Maybe I’m overlooking something obvious?

Also, when editing YAML, if you highlight a bunch of lines (or several thousand lines…) you can hit tab to indent it all two spaces, twice for 4 spaces which is what we need here, making quick work of the above. I was able to recreate my substantial dashboard using Sections following the above steps in only a few minutes! And be able to drag stuff around is great.

Just that they’re not as wide as they need to be 😦 And if someone knows how to address that, maybe they also know how to adjust the gap between sections? That’d be handy too.

Ironically, I just did the same this morning. The Sections capability is good. I hope they make the ability to expand the width of certain cards (e.g. entity, button) to the whole section. I have several Mushroom Template cards that are assigned to two columns in a section row, which I would prefer to take up the whole row given the information they contain.

Change the layout type on the card from “default” to either horizontal or vertical, then it will fill the whole row. I had the same issue at first.

Thank you, it works again with https://github.com/sdrapha/lovelace-layout-card/blob/fix_break_card_ha_2024.6/layout-card.js. 👍 Don’t forget to replace file in layout-card.js.gz as well (or maybe just remove this gz file), and increase version in resource URL.

is this mod even still being maintained??

Yeah the drag and drop is a cool feature and also being able to add columns by dragging a slider is neat. Looks like I will start copy and pasting my cards over to new Sections views as it cannot be migrated.

If you look back through this thread, there are steps to migrate manually. I did this with a dashboard with dozens of complex cards and it only took about five minutes. Super happy with the result. Note that for the bit about having to indent everything (thousands of lines in my case) you can just highlight the text and hit tab (twice here) to make quick work of it.

Adding the layout type was a work around but caused the edit button issue. The fix in the .js file made it all work again so you don’t need layout type in the yaml … but remember to clear browser cache after replacing the .js file

Where do I add the ha-view-sections-… variables in the yaml - to the dashboard raw config? what if I’m not using a theme?

I moved to a grid-layout, it works as expected without using layout-break card and I can still use UI to edit elements.

title: Home
views:
  - title: Home
    theme: Mushroom Shadow
    icon: mdi:home
    type: custom:grid-layout
    layout:
      grid-template-columns: 33% 33% 33%
      grid-template-rows: auto
      grid-gap: 10px
      padding: 0 5px
    cards:
      - type: vertical-stack
        cards:
          [...]
      - type: vertical-stack
        cards:
          [...]
      - type: vertical-stack
        cards:
          [...]

You can customize the width and the height on the card using yaml in section card. We are looking to bring that to the UI. This feature is not documented yet because it’s experimental and may change (although I don’t think that will change 😅)

layout_options:
   grid_rows: 4         # number of row for your card in the grid
   grid_columns: 4      # number of column for your card in the grid

Just found a work around. Add a vertical stack to the Section that contains the cards you want to occupy a whole row.

I went ahead and copy-pasted my dashboards to the new Drag and Drop dashboard layout, and it works quite well with similar Column concepts.

This spells the end of the road for Layout Card for me, and I expect due to the new layout tools, there will be decreasing need for it in the future. Maybe not time for everyone, but for me it works.

Thanks for all the fish. Cheers.

Yep. I transferred one of my views to a “Sections” type today and it works great plus displays more consistently across devices for me. I think I’ll probably be doing the rest of my views when I have time and then bin this.