Button card


The button card allows you to add buttons to perform tasks.

Screenshot of three button cards Screenshot of three button cards.

To add the button card to your user interface:

  1. In the top right of the screen, select the pencil icon.
    • If this is your first time editing a dashboard, the Edit dashboard dialog appears.
      • By editing the dashboard, you are taking over control of this dashboard.
      • This means that it is no longer automatically updated when new dashboard elements become available.
      • To continue, in the dialog, select the three dots menu, then select Take control.
  2. Add a card to your dashboard.

All options for this card can be configured via the user interface.

Card settings

Entity

The entity ID the card interacts with, for example, light.living_room.

Name

The button name that is displayed on the card. If this field is left blank and the card interacts with an entity, the button name defaults to the entity name. Otherwise, no name is displayed.

Icon

The icon that is displayed on the card. If this field is left blank and the card interacts with an entity, the icon defaults to the entity domain icon. Otherwise, no icon is displayed.

Show Name

A toggle to show or hide the button name.

Show Icon

A toggle to show or hide the icon.

Icon Height

The height of the icon, in pixels.

Theme

Name of any loaded theme to be used for this card. For more information about themes, see the frontend documentation.

Tap Action

The action taken on card tap. For more information, see the action documentation.

Hold Action

The action taken on card tap and hold. For more information, see the action documentation.

YAML configuration

The following YAML options are available when you use YAML mode or just prefer to use YAML in the code editor in the UI.

Configuration Variables

type string Required

button

entity string (Optional)

The entity ID the card interacts with, for example, light.living_room.

name string (Optional, default: Entity name)

The button name that is displayed on the card. It defaults to the entity name only if the card interacts with an entity. Otherwise, if not configured, no name is displayed.

icon string (Optional, default: Entity domain icon)

The icon that is displayed on the card. It defaults to the entity domain icon only if the card interacts with an entity. Otherwise, if not configured, no icon is displayed.

show_name boolean (Optional, default: true)

If false, the button name is not shown on the card.

show_icon boolean (Optional, default: true)

If false, the icon is not shown on the card.

show_state boolean (Optional, default: false)

Show state.

icon_height string (Optional, default: auto)

The height of the icon. Any CSS value may be used.

state_color boolean (Optional, default: true)

If false, the icon does not change color when the entity is active.

tap_action map (Optional)

The action taken on card tap. For more information, see the action documentation.

hold_action map (Optional)

The action taken on card tap and hold. For more information, see the action documentation.

double_tap_action map (Optional)

The action taken on card double-tap. For more information, see the action documentation.

theme string (Optional)

Override the used theme for this card with any loaded theme. For more information about themes, see the frontend documentation.

action_name string (Optional, default: Run)

Override the default action name for a button row.

Examples

Basic example:

type: button
entity: light.living_room

Button card with a button name and a script that runs when card is tapped:

Screenshot of the Button card with script service Screenshot of the button card with script service.

type: button
name: Turn Off Lights
show_state: false
tap_action:
  action: call-service
  service: script.turn_on
  data:
    entity_id: script.turn_off_lights

Example of 4 buttons on a vertical stack card:

Screenshot of a vertical stack card with 4 buttons and an entity selector Screenshot of a vertical stack card with 4 buttons and an entity selector.

The image shows a vertical stack card with 4 buttons arranged in a horizontal stack card and an entity selector. The buttons use the toggle action to run a script, for example, the Netflix script, which starts up the TV and opens Netflix. To learn how to create scripts, refer to scripts.

cards:
  - entities:
      - entity: input_select.living_room_scene
        name: Scene
    show_header_toggle: false
    type: entities
  - type: horizontal-stack
    cards:
      - name: Watch Netflix
        entity: script.netflix
        type: button
        tap_action:
          action: toggle
        hold_action:
          action: more-info
        show_name: true
        show_icon: true
      - name: Watch YouTube
        entity: script.youtube
        type: button
        tap_action:
          action: toggle
        hold_action:
          action: more-info
        show_name: true
        show_icon: true
      - name: Wake PC
        entity: script.wake_on_lan
        type: button
        tap_action:
          action: toggle
        icon: mdi:desktop-tower
        show_name: true
        show_icon: true
        show_state: false
      - name: Go to sleep
        entity: script.sleep
        type: button
        tap_action:
          action: toggle
        icon: mdi:sleep
        hold_action:
          action: more-info
        show_name: true
        show_icon: true
type: vertical-stack