Decluttering Card Plus Contents ↓ GitHub ↗

Badges

Badges are the small pills across the top of a sections view. A badge template makes them reusable in exactly the way card does for cards.

Badges need the sections view type, so Home Assistant 2024.8 or newer.

decluttering_templates:
  power_badge:
    badge:
      type: entity
      entity: '[[entity]]'
      name: '[[name]]'
      color: '[[color]]'
      show_name: true
    default:
      - color: blue

Use it in a view’s badges: list:

views:
  - type: sections
    badges:
      - type: custom:decluttering-card-plus
        template: power_badge
        variables:
          - entity: sensor.solar_power
          - name: Solar
          - color: yellow
      - type: custom:decluttering-card-plus
        template: power_badge
        variables:
          - entity: sensor.house_power
          - name: House
          - color: red
      - type: custom:decluttering-card-plus
        template: power_badge
        variables:
          - entity: sensor.living_room_temperature
          - name: Living Room
          - color: green
    sections:
      - type: grid
        cards: []

Three badges built from one template, in yellow, red and green

Three badges, one template, one variable each for the bit that differs.


Adding one through the UI

While editing a sections view, click + Add badge, then By card, and search for declutter. Pick Decluttering Card Plus — the same card serves badges and cards, and it works out which you meant from the template you choose.

How it sits in the layout

Badges live in a flex row, so the wrapper gets out of the way completely rather than boxing the badge — it does not add a box, spacing, or a layout level of its own. Your badge sits in the row exactly as a normal one would.

One consequence: style reaches the badge itself, but there is no wrapper to paint on, so selectors aimed at the host have nothing to style. See Styling.

A badge per item (v1.11.0+)

A badge fills one slot, so a badge template cannot repeat by itself. A view can repeat it instead: one badge per person, per light, per anything Home Assistant knows about. See Repeating Sections and Badges.

views:
  - title: Home
    strategy:
      type: custom:decluttering-card-plus
      badges:
        - for_each_from: { domain: person }
          badge:
            type: custom:decluttering-card-plus
            template: person_badge
      sections: ...

The template gets each person’s entity and name without being passed them.

Any badge type

badge: takes any badge configuration Home Assistant supports, including custom badges from other integrations:

decluttering_templates:
  person_badge:
    badge:
      type: entity
      entity: '[[person]]'
      show_state: true
      show_name: true
      tap_action:
        action: more-info
badges:
  - type: custom:decluttering-card-plus
    template: person_badge
    variables:
      - person: person.john

Reference

Key Where Description
badge: template The badge configuration, with [[variables]]
default: template Fallback variable values
template: instance Name of the template
variables: instance Values to substitute

→ Cards · Rows · Elements