Iām playing with grid mode and have question. How to set grid cointener in center position? Where should I place ājustify-content: centerā?
This is not working:
- type: 'custom:grid-layout'
layout:
justify-content: center
grid-template-columns: 300px 300px 40%
grid-template-rows: auto
grid-template-areas: |
"header header2 header3"
badges: []
cards:
- type: entities
entities:
- entity: light.shelly_shbduo_1_d166ad
title: '1'
show_header_toggle: false
view_layout:
grid-area: header
- type: entities
entities:
- entity: light.shelly_shbduo_1_d166ad
title: '2'
show_header_toggle: false
view_layout:
grid-area: header2
- type: entities
entities:
- entity: light.shelly_shbduo_1_d166ad
title: '3'
show_header_toggle: false
view_layout:
grid-area: header3
sergio_pt
(Sergio_PT)
April 13, 2021, 7:44am
390
I believe this is the option:
place-items: start stretch
As an alternative, try to place columns with % on each side.
omayhemo
(Doug)
April 13, 2021, 5:29pm
392
Simplifying my previous post. As the instructions are, grid-view simply doesnāt work for me. What am I doing wrong?
- panel: true
layout:
grid-template-columns: auto 30px 25%
grid-template-rows: auto
grid-template-areas: |
"header header header"
"main . sidebar"
mediaquery:
"(max-width: 600px)":
grid-template-columns: 100%
grid-template-areas: |
"header"
"sidebar"
"main"
"(max-width: 800px)":
grid-template-columns: 50% 50%
grid-template-areas: |
"header sidebar"
"main main"
badges: []
cards:
- type: 'custom:layout-card'
layout_type: grid
layout: {}
cards:
- type: markdown
content: >
# Dummy 1
view_layout:
grid-area: header
- type: markdown
content: >
# Dummy 2
view_layout:
grid-area: main
- type: markdown
content: >
# Dummy 3
view_layout:
grid-area: sidebar
view_layout: {}
Result:
UPDATE:
I found a nice workaround on the github, posted by Jpsy
opened 09:34AM - 04 Apr 21 UTC
My Home Assistant version: 2021.3.4
Layout-card version (FROM BROWSER CONSOLE): 2.2.3
The Layout Options box content is stored in a YAML field called...
CDRX2
(CDRX2)
April 13, 2021, 8:49pm
393
Looks like youāre mixing the layout options at the view level an the layout-card. Try this:
- panel: true
layout:
grid-template-columns: auto 30px 25%
grid-template-rows: auto
grid-template-areas: |
"header header header"
"main . sidebar"
mediaquery:
"(max-width: 600px)":
grid-template-columns: 100%
grid-template-areas: |
"header"
"sidebar"
"main"
"(max-width: 800px)":
grid-template-columns: 50% 50%
grid-template-areas: |
"header sidebar"
"main main"
badges: []
cards:
- type: markdown
content: >
# Dummy 1
view_layout:
grid-area: header
- type: markdown
content: >
# Dummy 2
view_layout:
grid-area: main
- type: markdown
content: >
# Dummy 3
view_layout:
grid-area: sidebar
omayhemo
(Doug)
April 13, 2021, 9:26pm
394
Thanks ya, youāre right, typo in my repro of the issue.
But the real issue is that the UI layout_options seems to bugger up everytime you save, you have to use the layout: attribute as you have in your example with but with references to the layout_view, otherwise everytime you save at the UI itāll remove everything. Seems like a bug.
Hi there, is there away to put a background color to a grid area?
I have tried this, but now result.
views:
- title: testing
panel: false
path: testing
type: 'custom:grid-layout'
layout:
grid-template-columns: 25% auto 25%
grid-template-rows: null
grid-template-areas: |
"header header header"
"sidebar main main"
"footer footer footer"
grid-area: sidebar;
background-color: #ff0000
badges: []
cards:
- type: button
tap_action:
action: toggle
entity: sensor.energy_production_tarif_1
show_name: true
show_icon: true
show_state: true
title: homey
omayhemo
(Doug)
April 17, 2021, 12:21am
396
You can use card-mod found on HACS
Card-mod is only for cards. I donāt want to change the color of the card, but the grid-area.
CDRX2
(CDRX2)
April 17, 2021, 10:11am
398
Should work nonetheless if you include your grid card in a mod-card. See the card-mod docs, styling elements without ha-card.
1 Like
omayhemo
(Doug)
April 17, 2021, 4:45pm
399
It works if you use the mod-card card per the documentation. Youāll need to apply a proper height, to get the mod-card to fill the background.
type: 'custom:mod-card'
card:
type: 'custom:layout-card'
layout_type: grid
layout: {}
cards:
- type: entity
entity: sensor.atrium_temperature_offset
- type: entity
entity: sensor.atrium_temperature_offset
view_layout: {}
card_mod:
style: |
ha-card {
background-color: yellow;
height: 100%
}
1 Like
Thank you, this is getting closer. But for now I donāt get a particular grid in a specific color. I have try several things but with now results.
What I want for example is:
grid-area: sidebar. >> background yellow
grid-area: header >> background green
grid-area: footer >> background blue
omayhemo
(Doug)
April 19, 2021, 1:49pm
402
Nope, I havenāt figured that one out yet. As far as I can tell, I havenāt been able to select the hui-entity-card by walking the DOM using a mod card. Just keep fiddling with it and looking at the inspector and seeing what you can find. However, if you set the background of all the cards in that grid-area, they should appear seamless
Ok. I will search further
Thans you for your time.
heartkingz
(Heartkingz)
April 22, 2021, 5:49pm
404
Corey_Maxim:
blank
Have you ever fixed this issue? Iām experiencing this as well when i cast to a Nest Hubā¦
No unfortunately, I gave up. I probably will eventually try it again as I can see many uses for this for sure! Good luck I hope you figure it out
hankanman
(Hankanman)
April 25, 2021, 6:30pm
406
Hi All,
Had fun pulling my hair out with this one, can anyone tell me how to remove the margin at #root > * for all child cards of layout card?
This is the property i want to negate:
1 Like
CDRX2
(CDRX2)
April 25, 2021, 6:52pm
407
You have to use custom:mod-card
to get to this property.
hankanman
(Hankanman)
April 25, 2021, 6:52pm
408
Yeah been playing with that, but canāt figure out the right syntax to get there
CDRX2
(CDRX2)
April 25, 2021, 7:15pm
409
This works for me:
- type: 'custom:mod-card'
card_mod:
style:
layout-card$:
grid-layout$: |
:host {
padding: 0px !important;
}
#root {
margin: 0px !important;
}
#root > * {
margin: 0px !important;
}
card:
type: 'custom:layout-card'
...
Or you can try:
- type: 'custom:layout-card'
style:
'--masonry-view-card-margin': 0px
That might work as well.
1 Like
hankanman
(Hankanman)
April 26, 2021, 8:27am
410
And suddenly the shadow roots make sense! thank you, been bugging me that one, okay one more, how can i get a layout card to fill all available vertical space?
Setting the #root of grid-layout to 100% doesnāt change anything, but setting a hard value (like 1000px) does, so i know its the one i want to change to fill the square grid it is part of (see parent grid highlighted in light green). I want to fill the remaining vertical space per the arrows