You are reading the development docs (2026.12.1-dev.1): features here may not be released yet.
Skip to content

Content and Formats ​

What a text field shows: fixed text, or a template that follows an entity, and how entity states and attributes are written out. The other field keys are on the Text Fields page.

content ​

The text the field shows: plain words, or a template that works out a value. Templates follow their entities, so the text changes when the state does.

  • content takes all four template types: {entity.state} tokens, [[[ ]]] JavaScript, {{ }} Jinja2 (worked out by Home Assistant) and {ds:name} data sources.
  • Set template: false to show text such as {entity.state} literally.
  • A field whose content comes out empty is not drawn.
yaml
type: custom:lcards-button
entity: light.kitchen
preset: lozenge
text:
  default:
    font_size: 13
    color: var(--lcars-black)
  token:
    content: "{entity.state}" # token
    position: top-left
  script:
    content: "[[[return Math.round((entity.attributes.brightness || 0) / 255 * 100) + '%']]]" # JavaScript
    position: top-right
  literal:
    content: "{entity.state}"
    template: false # shown as written
    position: bottom-left
grid_options:
  rows: 2
yaml
# Token substitution
content: "{entity.state}"
content: "{entity.attributes.brightness}"
content: "{theme:colors.text.onDark}"

# JavaScript
content: "[[[return Math.round(entity.attributes.brightness / 255 * 100) + '%']]]"

# Jinja2 (worked out by Home Assistant)
content: "{{ states('sensor.temperature') }}°C"

# Data source: Home Assistant's own formatting, with the unit
content: "{ds:temp}"
# Data source: your own precision, and your own unit
content: "{ds:temp:.1f} °C"
KeyTypeDefaultDescription
contentstringfrom the preset, else -The text. Templates are worked out unless template is false
templatebooleantruefalse shows {...} and [[[...]]] as written

display_format ​

How entity values in content tokens are written: as Home Assistant shows them, as the raw state, or as value and unit. A door sensor reads Open rather than on, as on Home Assistant's own cards.

  • Set it on one field, or in text.default for every field on the card.
  • It changes only the text. Which colour or state a card picks (active, inactive ...) always uses the raw state.
  • [[[ ]]] JavaScript always gets the raw entity, and {{ }} Jinja2 is formatted by Home Assistant, so neither is affected.
ValueShowsExample
friendlyHome Assistant's translated display text, as on its own cardsOpen
rawThe state or attribute exactly as storedon
partsThe value and unit from Home Assistant's formatter, joined23.5 °C
unitOnly the unit°C
yaml
type: custom:lcards-button
entity: sensor.outdoor_temperature
preset: lozenge
text:
  default:
    display_format: parts
    font_size: 16
    color: var(--lcars-black)
  reading:
    content: "{entity.state}" # 12.3 °C
    position: top-left
  unit:
    content: "{entity.state}"
    display_format: unit # °C only
    position: top-right
  stored:
    content: "{entity.state}"
    display_format: raw # 12.3
    position: bottom-left
grid_options:
  rows: 2
More about display_format
  • In JavaScript: call hass.formatEntityState(entity) in a [[[ ]]] template for the friendly text there.
  • Slider units: the units the slider adds to its labels come from the same Home Assistant formatter, so they match its display.
KeyTypeDefaultDescription
display_formatstringfriendlyfriendly, raw, parts or unit

Released under the MIT License. | About