Colours
Every colour key on every LCARdS card takes the same colour values: a CSS variable, a theme token, a colour function, or any CSS colour. A colour key can also take a state map, which picks a colour from the card's entity state.
- Colours built from CSS variables and theme tokens follow the alert mode: when red alert shifts the palette, they change with it, without a refresh. Hex and named colours stay as they are.
- A state map (
active,inactive,above:50, a state name ...) picks the colour as the entity changes; templates work too.
| Page | Covers |
|---|---|
| Colour Values | CSS variables, theme tokens, colour functions such as alpha() and darken(), base(), match-light |
| State Maps | Colours by state: state and number keys, the order they are checked in, where maps work, templates |
| Attributes and Buckets | Colours from an attribute (ranges_attribute, state_attribute) and your own state groups (state_classification) |
Quick start
Two examples to start from: one fixed colour, and a colour that follows the entity.
- A fixed colour is a plain value. A colour that follows the entity is a map of states to colours, with
defaultfor everything else.
yaml
type: custom:lcards-button
preset: lozenge
text:
label:
show: true
content: FIXED
style:
card:
color:
background: alpha(var(--lcars-blue), 0.6)yaml
type: custom:lcards-button
entity: input_boolean.lcards_test_toggle
preset: lozenge
text:
name:
show: true
tap_action:
action: toggle
style:
card:
color:
background:
active: var(--lcars-orange)
inactive: var(--lcars-gray)
unavailable: var(--lcars-alert-red)Colour value formats
What you can write in a colour key. Every format works in every colour key, on its own or as a value in a state map.
- Quote hex colours in YAML: unquoted,
#ff9900starts a comment and the key is left empty.
| Format | Example | Notes |
|---|---|---|
| CSS variable | var(--lcards-orange) | Any --lcards-*, --lcars-* or Home Assistant variable. See CSS variables |
| Theme token path | theme:colors.ui.primary | A colour from the active theme. See Theme token paths |
| Colour function | darken(var(--lcards-orange), 0.2) | alpha(), darken(), lighten(), saturate(), desaturate(), mix(), base(). See Computed colour tokens |
| Hex | "#F90", "#FF9900", "#FF990080" | 3, 4, 6 or 8 digits; the last digit (of 4) or pair (of 8) is the alpha |
| Named colour | black, orange, transparent | Any CSS colour name, in lower case, and currentColor |
| RGB / HSL | rgba(255, 153, 0, 0.5), hsl(36 100% 50%) | Comma or space syntax, optional / alpha |
| Other CSS colours | oklch(0.75 0.17 60), color-mix(in srgb, red 25%, blue) | hwb(), lab(), lch(), oklab(), oklch(), color(), color-mix() |
| Match light | match-light | The colour of the card's light entity. See match-light |
Card keys
Three top-level card keys change how state maps read the entity. They are on the Attributes and Buckets page.
yaml
type: custom:lcards-button
entity: light.tv
preset: lozenge
ranges_attribute: brightness_pct # ranges compare the brightness, 0 to 100
text:
name:
show: true
style:
card:
color:
background:
above:70: var(--lcars-yellow)
active: var(--lcars-orange)
inactive: var(--lcars-gray)| Key | Type | Default | Description |
|---|---|---|---|
ranges_attribute | string | the state | The attribute that range keys (above:N, between:N:M ...) compare: see ranges_attribute |
state_attribute | string | - | The attribute whose value picks exact-match keys: see state_attribute |
state_classification | object | - | Which states count as active or inactive, and your own named groups: see state_classification |