mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-14 21:06:50 +00:00
Improvements to picture-elements.markdown (#14144)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
937febbafa
commit
5e4a70bce1
@ -51,8 +51,23 @@ theme:
|
|||||||
|
|
||||||
## Elements
|
## Elements
|
||||||
|
|
||||||
|
Elements are the active components (icons, badges, buttons, text, etc.) that overlay the image.
|
||||||
|
|
||||||
|
There are several different element types that can be added to a Picture Elements card:
|
||||||
|
|
||||||
|
- [State Badge](#state-badge)
|
||||||
|
- [State Icon](#state-icon)
|
||||||
|
- [State Label](#state-label)
|
||||||
|
- [Service Call Button](#service-call-button)
|
||||||
|
- [Icon](#icon-element)
|
||||||
|
- [Image](#image-element)
|
||||||
|
- [Conditional](#conditional-element)
|
||||||
|
- [Custom](#custom-elements)
|
||||||
|
|
||||||
### State Badge
|
### State Badge
|
||||||
|
|
||||||
|
This element creates a badge representing the state of an entity.
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
type:
|
type:
|
||||||
required: true
|
required: true
|
||||||
@ -64,7 +79,7 @@ entity:
|
|||||||
type: string
|
type: string
|
||||||
style:
|
style:
|
||||||
required: true
|
required: true
|
||||||
description: Position and style the element using CSS.
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
type: map
|
type: map
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
title:
|
title:
|
||||||
@ -85,7 +100,9 @@ double_tap_action:
|
|||||||
type: map
|
type: map
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
### Icon representing an entity state
|
### State Icon
|
||||||
|
|
||||||
|
This element represents an entity state using an icon.
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
type:
|
type:
|
||||||
@ -158,12 +175,14 @@ double_tap_action:
|
|||||||
type: map
|
type: map
|
||||||
style:
|
style:
|
||||||
required: true
|
required: true
|
||||||
description: Position and style the element using CSS.
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
type: string
|
type: string
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
### Label with state text
|
### State Label
|
||||||
|
|
||||||
|
This element represents an entity's state via text.
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
type:
|
type:
|
||||||
@ -205,13 +224,15 @@ double_tap_action:
|
|||||||
type: map
|
type: map
|
||||||
style:
|
style:
|
||||||
required: true
|
required: true
|
||||||
description: Position and style the element using CSS.
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
type: string
|
type: string
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
### Service Call Button
|
### Service Call Button
|
||||||
|
|
||||||
|
This entity creates a button (with arbitrary text) that can be used to call a service.
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
type:
|
type:
|
||||||
required: true
|
required: true
|
||||||
@ -231,13 +252,15 @@ service_data:
|
|||||||
type: map
|
type: map
|
||||||
style:
|
style:
|
||||||
required: true
|
required: true
|
||||||
description: Position and style the element using CSS.
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
type: string
|
type: string
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
### Icon Element
|
### Icon Element
|
||||||
|
|
||||||
|
This element creates a static icon that is not linked to the state of an entity.
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
type:
|
type:
|
||||||
required: true
|
required: true
|
||||||
@ -269,13 +292,15 @@ double_tap_action:
|
|||||||
type: map
|
type: map
|
||||||
style:
|
style:
|
||||||
required: true
|
required: true
|
||||||
description: Position and style the element using CSS.
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
type: string
|
type: string
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
### Image Element
|
### Image Element
|
||||||
|
|
||||||
|
This creates an image element that overlays the background image.
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
type:
|
type:
|
||||||
required: true
|
required: true
|
||||||
@ -333,7 +358,7 @@ aspect_ratio:
|
|||||||
default: "50%"
|
default: "50%"
|
||||||
style:
|
style:
|
||||||
required: true
|
required: true
|
||||||
description: Position and style the element using CSS.
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
type: string
|
type: string
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
@ -370,6 +395,25 @@ elements:
|
|||||||
type: list
|
type: list
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
|
### Custom Elements
|
||||||
|
|
||||||
|
The process for creating and referencing custom elements is the same as for custom cards.
|
||||||
|
Please see the [developer documentation](https://developers.home-assistant.io/docs/frontend/custom-ui/lovelace-custom-card.html)
|
||||||
|
for more information.
|
||||||
|
|
||||||
|
{% configuration %}
|
||||||
|
type:
|
||||||
|
required: true
|
||||||
|
description: 'Card name with `custom:` prefix (e.g., `custom:my-custom-card`)'
|
||||||
|
type: string
|
||||||
|
style:
|
||||||
|
required: true
|
||||||
|
description: '[Position and style the element](#how-to-use-the-style-object) using CSS.'
|
||||||
|
type: string
|
||||||
|
default: "position: absolute, transform: translate(-50%, -50%)"
|
||||||
|
{% endconfiguration %}
|
||||||
|
|
||||||
|
|
||||||
## Options For Exemptions
|
## Options For Exemptions
|
||||||
|
|
||||||
{% configuration badges %}
|
{% configuration badges %}
|
||||||
@ -379,27 +423,12 @@ user:
|
|||||||
type: string
|
type: string
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
### Custom Elements
|
## Notes on Element Attributes
|
||||||
|
|
||||||
{% configuration %}
|
### How to use the style object
|
||||||
type:
|
|
||||||
required: true
|
|
||||||
description: 'Card name with `custom:` prefix (e.g., `custom:my-custom-card`)'
|
|
||||||
type: string
|
|
||||||
style:
|
|
||||||
required: true
|
|
||||||
description: Position and style the element using CSS.
|
|
||||||
type: string
|
|
||||||
default: "position: absolute, transform: translate(-50%, -50%)"
|
|
||||||
{% endconfiguration %}
|
|
||||||
|
|
||||||
The process for creating and referencing custom elements is the same as for custom cards.
|
Position and style your elements using [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS). More/other keys are also possible.
|
||||||
Please see the [developer documentation](https://developers.home-assistant.io/docs/frontend/custom-ui/lovelace-custom-card.html)
|
Note, the default style for most elements includes [translate](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate)(-50%, -50%), which means that the coordinates you provide will set the position of the center of the element.
|
||||||
for more information.
|
|
||||||
|
|
||||||
## How to use the style object
|
|
||||||
|
|
||||||
Position and style your elements using [CSS](https://en.wikipedia.org/wiki/Cascading_Style_Sheets). More/other keys are also possible.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
style:
|
style:
|
||||||
@ -410,7 +439,7 @@ style:
|
|||||||
"--paper-item-icon-color": pink
|
"--paper-item-icon-color": pink
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to use state_image
|
### How to use state_image
|
||||||
|
|
||||||
Specify a different image to display based on the state of the entity.
|
Specify a different image to display based on the state of the entity.
|
||||||
|
|
||||||
@ -420,7 +449,7 @@ state_image:
|
|||||||
"off": /local/living_room_off.jpg
|
"off": /local/living_room_off.jpg
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to use state_filter
|
### How to use state_filter
|
||||||
|
|
||||||
Specify different [CSS filters](https://developer.mozilla.org/en-US/docs/Web/CSS/filter)
|
Specify different [CSS filters](https://developer.mozilla.org/en-US/docs/Web/CSS/filter)
|
||||||
|
|
||||||
@ -430,7 +459,7 @@ state_filter:
|
|||||||
"off": brightness(50%) hue-rotate(45deg)
|
"off": brightness(50%) hue-rotate(45deg)
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to use click-and-hold
|
### How to use click-and-hold
|
||||||
|
|
||||||
If the option `hold_action` is specified, that action will be performed when the entity is clicked and held for half a second or more.
|
If the option `hold_action` is specified, that action will be performed when the entity is clicked and held for half a second or more.
|
||||||
|
|
||||||
@ -445,7 +474,9 @@ hold_action:
|
|||||||
brightness_pct: 100
|
brightness_pct: 100
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Examples
|
||||||
|
|
||||||
|
### Example of icons, labels and buttons
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: picture-elements
|
type: picture-elements
|
||||||
@ -495,7 +526,7 @@ elements:
|
|||||||
left: 10%
|
left: 10%
|
||||||
```
|
```
|
||||||
|
|
||||||
## Images Example
|
### Images Example
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: picture-elements
|
type: picture-elements
|
||||||
@ -544,7 +575,7 @@ elements:
|
|||||||
width: 5%
|
width: 5%
|
||||||
```
|
```
|
||||||
|
|
||||||
## Conditional Example
|
### Conditional Example
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: picture-elements
|
type: picture-elements
|
||||||
|
Loading…
x
Reference in New Issue
Block a user