Skip to content

Commit 4479af8

Browse files
authored
Use grid options instead of layout options (#2440)
* Use grid options instead of layout options * Add default values
1 parent 63dfc91 commit 4479af8

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

docs/frontend/custom-ui/custom-card.md

+22-20
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ class ContentCardExample extends HTMLElement {
5252
}
5353

5454
// The rules for sizing your card in the grid in sections view
55-
getLayoutOptions() {
55+
getGridOptions() {
5656
return {
57-
grid_rows: 3,
58-
grid_columns: 2,
59-
grid_min_rows: 3,
60-
grid_max_rows: 3,
57+
rows: 3,
58+
columns: 6,
59+
min_rows: 3,
60+
max_rows: 3,
6161
};
6262
}
6363
}
@@ -106,37 +106,39 @@ return customElements
106106

107107
### Sizing in sections view
108108

109-
You can define a `getLayoutOptions` method that returns the min, max and default number of cells your card will take in the grid if your card is used in the [sections view](https://www.home-assistant.io/dashboards/sections/).
110-
If you don't define this method, the card will take 4 columns (full width) and will ignore the rows of the grid.
109+
You can define a `getGridOptions` method that returns the min, max and default number of cells your card will take in the grid if your card is used in the [sections view](https://www.home-assistant.io/dashboards/sections/). Each section is divided in 12 columns.
110+
If you don't define this method, the card will take 12 columns and will ignore the rows of the grid.
111111

112112
A cell of the grid is defined with the following dimension:
113113

114-
- width: between `80px` and `120px` depending on the screen size
114+
- width: width of the section divided by 12 (approximately `30px`)
115115
- height: `56px`
116116
- gap between cells: `8px`
117117

118-
The different layout options are:
118+
The different grid options are:
119119

120-
- `grid_rows`: Default number of rows the card takes
121-
- `grid_min_rows`: Minimal number of rows the card takes
122-
- `grid_max_rows`: Maximal number of rows the card takes
123-
- `grid_columns`: Default number of columns the card takes
124-
- `grid_min_columns`: Minimal number of columns the card takes
125-
- `grid_max_columns`: Maximal number of columns the card takes
120+
- `rows`: Default number of rows the card takes. Do not define this value if you want your card to ignore the rows of the grid (not defined by default)
121+
- `min_rows`: Minimal number of rows the card takes (`1` by default)
122+
- `max_rows`: Maximal number of rows the card takes (not defined by default)
123+
- `columns`: Default number of columns the card takes. Set it to `full` to enforce your card to be full width, (`12` by default)
124+
- `min_columns`: Minimal number of columns the card takes (`1` by default)
125+
- `max_columns`: Maximal number of columns the card takes (not defined by default)
126+
127+
For the number of columns, it's `highly` recommended to use multiple of 3 for the default value (`3`, `6`, `9` or `12`) so your card will have better looking on the dashboard by default.
126128

127129
Example of implementation:
128130

129131
```js
130-
public getLayoutOptions() {
132+
public getGridOptions() {
131133
return {
132-
grid_rows: 2,
133-
grid_columns: 2,
134-
grid_min_rows: 2,
134+
rows: 2,
135+
columns: 6,
136+
min_rows: 2,
135137
};
136138
}
137139
```
138140

139-
In this example, the card will take 2 x 2 cells by default. The height of the card cannot be smaller than 2 rows. According to the cell dimension, the card will have a height of `120px` (`2` * `56px` + `8px`).
141+
In this example, the card will take 6 x 2 cells by default. The height of the card cannot be smaller than 2 rows. According to the cell dimension, the card will have a height of `120px` (`2` * `56px` + `8px`).
140142

141143
## Advanced example
142144

0 commit comments

Comments
 (0)