You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/frontend/custom-ui/custom-card.md
+22-20
Original file line number
Diff line number
Diff line change
@@ -52,12 +52,12 @@ class ContentCardExample extends HTMLElement {
52
52
}
53
53
54
54
// The rules for sizing your card in the grid in sections view
55
-
getLayoutOptions() {
55
+
getGridOptions() {
56
56
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,
61
61
};
62
62
}
63
63
}
@@ -106,37 +106,39 @@ return customElements
106
106
107
107
### Sizing in sections view
108
108
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.
111
111
112
112
A cell of the grid is defined with the following dimension:
113
113
114
-
- width: between `80px` and `120px` depending on the screen size
114
+
- width: width of the section divided by 12 (approximately `30px`)
115
115
- height: `56px`
116
116
- gap between cells: `8px`
117
117
118
-
The different layout options are:
118
+
The different grid options are:
119
119
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.
126
128
127
129
Example of implementation:
128
130
129
131
```js
130
-
public getLayoutOptions() {
132
+
public getGridOptions() {
131
133
return {
132
-
grid_rows: 2,
133
-
grid_columns: 2,
134
-
grid_min_rows: 2,
134
+
rows: 2,
135
+
columns: 6,
136
+
min_rows: 2,
135
137
};
136
138
}
137
139
```
138
140
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`).
0 commit comments