Card guide Home Assistant custom cards
Button Card for Home Assistant
One card type that can be a light switch, a lock with colours for each state, or a whole room summary. Everything is set in YAML, and any field can be worked out with a JavaScript template.
What it is
Button Card is one card type with a long list of options. You give it an entity, or none at all, and then decide what it shows, how it's laid out and how it changes with state. Every example below is the same custom:button-card configured differently.
Most of its power comes from JavaScript templates. Any field wrapped in [[[ ]]] is worked out in the browser from the current states, so a label can count lights, a colour can follow a sensor, and a custom field can pull in an entity the card isn't attached to. Configuration templates go further: you define a style once at the top of the dashboard and reuse it on every button. The polamoros room and notification cards are built that way.
Expect to set it up in YAML. In a sections view, add section_mode: true and the card resizes with grid_options like a core card does.
It installs through HACS.
What it gives you
Shot on Home Assistant 2026.10.1. Stock is Home Assistant with no theme installed; a theme changes how these look, not what they do.
Light button
custom:button-card The whole card takes the light's current colour, and the icon and text switch to stay readable on it.
Show the YAML
type: custom:button-card
entity: light.living_lights
name: Living Lights
show_state: true
color_type: card
color: auto
section_mode: true
grid_options:
columns: 12
rows: 3 Icon tiles
custom:button-card Four buttons in a square grid, each icon coloured to match its light, and greyed with a strike-through when the light is off.
Show the YAML
type: grid
columns: 4
square: true
grid_options:
columns: 12
cards:
- type: custom:button-card
entity: light.kitchen_lights_2
name: Kitchen
color: auto
- type: custom:button-card
entity: light.dining_lights
name: Dining
color: auto
- type: custom:button-card
entity: light.hue_color_lamp_1
name: Lamp
color: auto
- type: custom:button-card
entity: light.garage
name: Garage
color: auto State styles
custom:button-card A different icon and colour for each state, so a locked door shows a green padlock and an unlocked one shows red.
Show the YAML
type: horizontal-stack
grid_options:
columns: 12
cards:
- type: custom:button-card
entity: lock.front_door
name: Front Door
show_state: true
state:
- value: locked
icon: mdi:lock
color: rgb(76, 175, 80)
- value: unlocked
icon: mdi:lock-open-variant
color: rgb(244, 67, 54)
- type: custom:button-card
entity: lock.kitchen_door
name: Kitchen Door
show_state: true
state:
- value: locked
icon: mdi:lock
color: rgb(76, 175, 80)
- value: unlocked
icon: mdi:lock-open-variant
color: rgb(244, 67, 54) Room card
custom:button-card Custom fields add the room's temperature, window and fan to one card, laid out with a CSS grid.
Show the YAML
type: custom:button-card
entity: light.living_lights
name: Living
icon: mdi:sofa
section_mode: true
grid_options:
columns: 12
rows: 2
custom_fields:
temp: "[[[ return `<ha-icon icon=\"mdi:thermometer\" style=\"width:16px\"></ha-icon> ${states['climate.living'].attributes.current_temperature}\xB0C`; ]]]\n"
window: '[[[ const s = states[''cover.living_room_window''].state; return `<ha-icon icon="mdi:window-${s === ''open'' ? ''open'' : ''closed''}-variant" style="width:16px"></ha-icon> ${s === ''open'' ? ''Open'' : ''Closed''}`; ]]]
'
fan: '[[[ const s = states[''fan.living_room_fan''].state; return `<ha-icon icon="mdi:fan" style="width:16px"></ha-icon> ${s === ''on'' ? ''On'' : ''Off''}`; ]]]
'
styles:
card:
- padding: 12px 16px
grid:
- grid-template-areas: '"i n n n" "i temp window fan"'
- grid-template-columns: 64px 1fr 1fr 1fr
- grid-template-rows: 1fr 1fr
img_cell:
- background: rgba(var(--rgb-primary-color), 0.15)
- border-radius: 50%
- width: 52px
- height: 52px
icon:
- width: 28px
- color: var(--primary-color)
name:
- justify-self: start
- font-size: 18px
- font-weight: 500
custom_fields:
temp:
- justify-self: start
- font-size: 14px
window:
- justify-self: start
- font-size: 14px
fan:
- justify-self: start
- font-size: 14px Template label
custom:button-card A JavaScript template counts the lights that are on and writes the label, here "5 of 6 lights on".
Show the YAML
type: custom:button-card
icon: mdi:lightbulb-group
name: Downstairs
show_label: true
layout: icon_name_state2nd
section_mode: true
grid_options:
columns: 12
rows: 2
label: '[[[ const ids = [''light.kitchen_lights_2'', ''light.dining_lights'', ''light.living_lights'', ''light.hue_color_lamp_1'', ''light.hallway'', ''light.powder_room'']; const on = ids.filter((e) => states[e].state === ''on'').length; return `${on} of ${ids.length} lights on`; ]]]
'
styles:
grid:
- grid-template-columns: 72px 1fr
icon:
- width: 36px
- color: 'var(--state-light-on-color, #ffb74d)'
name:
- &id001
justify-self: start
- font-size: 18px
- font-weight: '500'
label:
- *id001
- font-size: 14px Lock
custom:button-card A padlock in the corner means the first tap unlocks the card, and only a second tap opens the garage door.
Show the YAML
type: custom:button-card
entity: cover.garage_door
name: Garage Door
show_state: true
layout: icon_name_state2nd
section_mode: true
grid_options:
columns: 12
rows: 2
tap_action:
action: toggle
lock:
enabled: true
duration: 5
styles:
grid:
- grid-template-columns: 72px 1fr
icon:
- width: 36px
name:
- &id001
justify-self: start
- font-size: 18px
- font-weight: '500'
state:
- *id001
- font-size: 14px The repository
- Author
- RomRider @custom-cards
- Latest release
- v7.1.1 30 November 2026
- GitHub stars
- 2.5k
- Install via
- HACS Free, MIT
Maintenance: The last stable release was 7.0.1 in November 2025. A 7.1 beta has been out since April 2026, and the repository has had little work since. Set section_mode: true to make it size itself like a core card in a sections view.
Built in instead: Home Assistant's own Tile and Button cards cover a plain on/off control with nothing to install. Button Card is for when you want a layout, a value or a colour those cards can't give you.
Frequently asked questions
Is Button Card the same as Home Assistant's Button card?
No. The core Button card is type: button and shows an icon, a name and optionally the state, with tap and hold actions. Button Card is type: custom:button-card, installs from HACS and adds states, layouts, custom fields and templates.
Why does my button look the wrong size in a sections view?
Without section_mode: true it keeps its own sizing, so it doesn't fill the grid cell. Turn it on and set the size with grid_options. Leave aspect_ratio out, as the two don't mix.
Where do the JavaScript templates run?
In your browser, each time an entity the template reads changes. The states object holds every entity, so a card can read sensors it isn't attached to.
Can I stop a button being tapped by accident?
Yes. lock: enabled: true puts a padlock on the card, and a tap unlocks it for five seconds. You can change the duration, unlock with a hold instead, or exempt named users.
Still need a hand?
We answer most messages within one business day. If your question is about an existing order, have your order number ready. It speeds things up.
Contact us