🔹 Layout-card - Take control of where your cards end up

yeah thanks that is great to know.
I guess the issue is with the horizontal layout in that case, so the question stands :wink:
this is my swipe-card config:

    - type: custom:swipe-card
      parameters:
        spaceBetween: 8
        effect: coverflow
        grabCursor: true
        centeredSlides: false # to have the swipe card start left side
        slidesPerView: 4 # to auto render the correct size of the buttons, 4 in a row always
        coverflowEffect:
          rotate: 50
          depth: 100
          modifier: 1
          slideShadows : true
        pagination:
          type: bullets
          hideOnClick: true
      cards:
        !include /config/lovelace/buttons/buttons_alerts_swipe.yaml

having it display for cards by default, even if there are less than 4 (to have the button-cards it displays always show the correct format of 4 in a row)

to give you an idea, the button_alerts_swipe lists the conditional button-cards like:

etc
etc
- type: conditional
  conditions:
    - entity: binary_sensor.updater_notification
      state: 'on'
  card: !include /config/lovelace/includes/include_button_updater.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.addon_updates_available
      state: 'on'
  card: !include /config/lovelace/includes/include_button_addons_updates_available.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.meteoalarm_brabant
      state: 'on'
  card: !include /config/lovelace/includes/include_button_meteoalarm_alert.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.hubs_offline
      state: 'on'
  card: !include /config/lovelace/includes/include_button_sensor_hubs.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.critical_devices_offline
      state: 'on'
  card: !include /config/lovelace/includes/include_button_critical_devices.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.espresso_needs_refill
      state: 'on'
  card: !include /config/lovelace/includes/include_button_espresso.yaml

etc
etc

Could you perhaps assist me to create that in grid? I only need a vertical stack but with the column set to 96%. I tried myself but can’t get it to work.

Hi,
Thank you for the great update!
I create a nice layout using grid type in you card to fit 3 buttons in a row when on iPhone, and 5 buttons in a row when on bigger screens, which works perfectly.
This is the code:

  - type: custom:layout-card
    layout_type: grid

    layout_options:
      grid-template-columns: 1fr 1fr 1fr 1fr 1fr
      grid-template-rows: auto
      grid-gap: 0px 2px
      mediaquery:
        "(max-width: 450px)":
          grid-template-columns: 1fr 1fr 1fr

However it always seems that the row height is slightly bigger then width, although the button inside is always with ratio 1/1.
Can you please advise if there is an option to set each item ration to 1/1, or maybe limit the height to be exactly as contained button inside?

Thanks in advance.

4 Likes

layout card is installed with HACS

image

but i ve no layout tab
image

…empty:

Sorry to ask a question instead of providing an answer. But I think you have experience and can help me judging by your code.

Can you help me in how to create a layout card using grid that consists of only one column with a max width of 96%? Basically my goal is to have a column that is 96% of the screen width.

The previous card version could do that with vertical layout mode and had it working. But now with 2.0 I need to use grid layout according to card developer. It does not work with previous code.

Hi,
I myself only started to learn the grid options, Thomas actually put link to CSS Grid page which was a big help, suggest you to go over it.
Having said that, you can try something like this:

  - type: custom:layout-card
    layout_type: grid

    layout_options:
      grid-template-columns: 96%
      grid-template-rows: auto

    cards:
1 Like

Thanks, that works :smiley:! I’m new to CSS and learning some stuff and will checkout grid. Thanks for your help!

Try clearing your browser cache…

Aha, the new layouts are for the entire page and aren’t cards. Thanks Thomas, this is great work.

1 Like

Have it, no result.

image

image

Hi @thomasloven,
I was trying the below grid layout in order to have 2px empty shoulders, however in my case the “.” areas are still being populated with cards.
Am I missing something here?

  - type: custom:layout-card
    layout_type: grid

    layout_options:
      grid-template-columns: 2px 1fr 1fr 1fr 1fr 1fr 2px
      grid-template-rows: auto
      grid-template-areas: |
        ". none none none none none ."
      grid-gap: 0px 4px

What is your Home Assistant version, and what do you see in the browser console?

i have now removed all, and make it clean install of this addon with hacs. no layout tab

i use Home Assistant 2021.3.4

Either the upgrade failed, or your browser does not agree that you cleared the cache.
It should ideally say “LAYOUT-CARD 2.1.0 IS INSTALLED”

Hi @noxx ,
Happened to me as well, in fact it is still happening on my main Chrome browser. It will be refreshed at some point eventually.
However on other devices it was refreshed almost immediately.

The solution for Chrome is to use incognito mode for now, in order to work on HA changes, until it will be refreshed at some point.

Following the directions linked from the readme seems to have a high rate of success too…
https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins#clearing-cache

works now. thx

Hello! Is there still a way of doing this kind of cards?


Can’t mange with 2.0+. They where not perfect because filled more space than the other cards and had no separation between them, but I could control each card dimensions. Thanks for your work!!!

Hello guys, i’m trying to place a grid layout inside another one.
I’ll try to paste as less code as I can to explain:

title: Home 
views: 

  - title: Home
    path: home
    icon: 'mdi:home-roof'
    panel: false
    type: custom:grid-layout
    layout:
      grid-template-columns: 7% auto 23%
      grid-template-rows: 100%
      grid-template-areas: |
        "sidebarsx main sidebardx"
    badges: []
    cards:
      - type: custom:stack-in-card #Used to apply styling, as Card-Mod doesn't work on Vertical-Stack
        layout:
          grid-area: sidebarsx
        cards:
          - Other Stuff for a left Sidebar...

      - type: vertical-stack
        layout:
          grid-area: main
        cards:
          - type: 'custom:layout-card' <--- Here is my problem
            layout_type: grid
            layout:
              grid-template-columns: 40% 60%
              grid-template-rows: 100%
              grid-template-areas: |
                "left right free"
            cards:

              - type: 'custom:simple-weather-card'
                layout:
                  grid-area: left
                other stuff...

               - type: 'custom:atomic-calendar-revive'
                 layout:
                   grid-area: right
                 entities:
                   - entity: calendar.casa # Use your Calendar entity
                other stuff...
This is the expected behavior:

What actually I got:

Can someone help me?
Thank you!

I can’t reproduce this problem

Are you sure you have specified grid-area correctly on all cards?

Try setting it up as simply as possible in a new view, one step at a time.

 - title: a
    path: a
    type: 'custom:grid-layout'
    layout:
      grid-template-columns: 7% auto 23%
      grid-template-rows: 100%
      grid-template-areas: |
        "sidebarsx main sidebardx"
    badges: []
    cards:
      - type: vertical-stack
        cards:
          - <<: &card
              type: button
              entity: light.bed_light
          - <<: *card
          - <<: *card
          - <<: *card
        layout:
          grid-area: sidebarsx
      - type: vertical-stack
        cards:
          - type: 'custom:layout-card'
            cards:
              - <<: *card
                layout:
                  grid-area: left
              - <<: *card
                layout:
                  grid-area: right
            layout_type: grid
            layout_options:
              grid-template-columns: 40% 60%
              grid-template-rows: 100%
              grid-template-areas: |
                "left right free"
            layout:
              layout_type: masonry
              layout_options: {}
          - type: grid
            cards:
              - <<: *card
              - <<: *card
              - <<: *card
              - <<: *card
        layout:
          grid-area: main
      - type: vertical-stack
        cards:
          - <<: *card
          - <<: *card
        layout:
          grid-area: sidebardx