Skip to content

Button Card

custom:lcards-button

The Button card covers everything from simple labels and toggle buttons to complex interactive components like D-pads and multi-segment SVG controls. Elbows use the same base so every feature here is also available in the Elbow card.


Modes

The card operates in one of three modes, selected by which top-level key is present:

ModeKeyUse for
PresetpresetStandard LCARS buttons — lozenge, bullet, capped, etc.
ComponentcomponentInteractive multi-segment controls (D-pad, alert shape)
Custom SVGsvgYour own SVG with interactive segments

Top-Level Options

OptionTypeDescription
typestringcustom:lcards-button (required)
entitystringEntity to monitor and control
idstringCustom card ID for rule targeting
tagslistTags for rule targeting (e.g. [nav, lights])
presetstringButton shape preset (preset mode)
componentstringComponent type: dpad or alert (component mode)
svgobjectCustom SVG config (svg mode)
textobjectText field definitions — see Text Fields
iconstringMDI icon (e.g. mdi:lightbulb)
icon_areastringIcon position: left, right, top, bottom, none
icon_area_sizenumberIcon area width/height in px (default: 60)
icon_styleobjectAdvanced icon styling — see below
dividerobjectDivider between icon area and content area — see below
styleobjectVisual styles — see below
tap_actionobjectTap action — see Actions
hold_actionobjectHold action
double_tap_actionobjectDouble-tap action
animationslistCard animations — see Animations
background_animationlist / objectCanvas background animations — see Background Animations
shape_textureobjectSVG texture inside the button fill — see below
filterslistCSS / SVG filters — see below
data_sourcesobjectDataSource definitions — see DataSources
soundsobjectPer-card sound overrides — see Sound Effects
grid_optionsobjectHA grid layout (columns, rows)

style Object

style.card

FieldTypeDescription
color.backgroundstring / objectCard background — state map supported

style.border

FieldTypeDefaultDescription
colorstring / objectthemeBorder colour — state map supported
widthnumber0Border width in px
radiusnumber / objectthemeCorner radius in px, or { top_left, top_right, bottom_left, bottom_right }
stylestringsolidCSS border-style (solid, dashed, dotted)

style.text.default and style.text.<field>

Shorthand for setting text styles inside the style block (equivalent to top-level text.default.*):

FieldTypeDescription
colorstring / objectText colour — state map supported
font_sizenumber / stringFont size in px or CSS value
font_weightstring / numberCSS font-weight
font_familystringCSS font-family

See Text Fields for the full per-field options table.

yaml
style:
  card:
    color:
      background:
        default: "var(--ha-card-background)"
        active: "alpha(var(--lcards-orange), 0.08)"
  border:
    color:
      default: "var(--lcards-gray)"
      active: "var(--lcards-orange)"
    width: 2
    radius: 12          # or per-corner: { top_left: 20, top_right: 4, bottom_left: 4, bottom_right: 20 }
  text:
    default:
      color: "var(--lcards-moonlight)"
      font_size: 13

icon_style Object

Fine-grained control over the icon appearance and placement within its area.

FieldTypeDescription
colorstring / objectIcon colour — state map supported
sizenumberIcon size in px
area_sizenumberWidth/height of the icon area in px
positionstringIcon position within its area
xnumberAbsolute X offset in px (overrides position)
ynumberAbsolute Y offset in px (overrides position)
x_percentnumberX as percentage of icon area width
y_percentnumberY as percentage of icon area height
rotationnumberIcon rotation in degrees
paddingnumber / objectPadding in px (number = all sides, or { top, right, bottom, left })
spacingnumberSpace between icon and text area (px)
yaml
icon: mdi:thermometer
icon_area: left
icon_style:
  color:
    default: "var(--lcards-gray)"
    active: "var(--lcards-orange)"
  size: 32
  padding: 8

divider Object

Thin line between the icon area and the content area.

FieldTypeDefaultDescription
colorstring / objectthemeDivider colour — state map supported
widthnumberthemeDivider thickness in px
yaml
divider:
  color: "var(--lcards-orange)"
  width: 2

filters List

CSS and SVG filters applied to the card.

FieldTypeDescription
modestringcss (default) or svg
typestringCSS type (blur, brightness, contrast, saturate, drop-shadow) or SVG primitive
valuestring / number / objectFilter parameters
yaml
filters:
  - type: blur
    value: 4

  - type: brightness
    value: 0.8

  - type: saturate
    value: 0.5

Text Fields

Multiple text labels can be placed anywhere on the card. See Text Fields for the full reference.

yaml
text:
  default:
    font_family: "Antonio, sans-serif"
    color: "var(--lcards-moonlight)"
  name:
    content: "Temperature"
    position: top-left
    font_size: 11
  value:
    content: "{entity.state}°C"
    position: center
    font_size: 28
    font_weight: bold
    color:
      default: "var(--lcards-moonlight)"
      unavailable: "var(--lcards-alert-red)"

Preset Mode

Available Presets

Common presets: lozenge, bullet, capped, outline, pill, text. Additional presets depend on installed packs — browse them in the card editor.


Component Mode: D-pad

D-pad segments: center, up, down, left, right, up-left, up-right, down-left, down-right

The default key under segments applies shared config to all segments.

FieldTypeDescription
entitystringEntity for this segment (state-based colours, icons)
tap_actionobjectAction on tap — see Actions
hold_actionobjectAction on hold
double_tap_actionobjectAction on double-tap
style.fillstring / objectSegment fill colour — state map supported
style.strokestring / objectSegment stroke colour
style.stroke_widthnumberStroke width in px
textobjectPer-segment text labels
iconstringMDI icon for this segment
animationslistSegment-specific animations
yaml
type: custom:lcards-button
component: dpad
dpad:
  segments:
    default:
      style:
        fill:
          default: "var(--lcards-gray)"
          active: "var(--lcards-orange)"
    center:
      entity: media_player.tv
      tap_action:
        action: call-service
        service: media_player.media_play_pause
        target:
          entity_id: media_player.tv
    up:
      tap_action:
        action: call-service
        service: media_player.volume_up
        target:
          entity_id: media_player.tv
    down:
      tap_action:
        action: call-service
        service: media_player.volume_down
        target:
          entity_id: media_player.tv

Component Mode: Alert

The alert component displays a Starfleet alert symbol with animated bar elements.

yaml
type: custom:lcards-button
component: alert
preset: default          # default, red, yellow, blue, green, grey, black

# State-driven preset switching
entity: sensor.threat_level
ranges:
  - preset: red
    above: 80
  - preset: yellow
    above: 50
  - preset: default
    above: 0

Custom SVG Mode

yaml
type: custom:lcards-button
svg:
  content: |
    <svg viewBox="0 0 200 100">
      <rect id="btn-a" x="10" y="10" width="80" height="80" fill="var(--lcards-orange)" rx="8"/>
      <rect id="btn-b" x="110" y="10" width="80" height="80" fill="var(--lcards-blue)" rx="8"/>
    </svg>
  segments:
    default:
      style:
        fill:
          active: "var(--lcards-orange-medium)"
    btn-a:
      entity: light.zone_a
      tap_action:
        action: toggle
    btn-b:
      entity: light.zone_b
      tap_action:
        action: toggle

SVG elements with id attributes become interactive segments.

Note: When using CSS custom properties in SVG fill attributes, browser support can vary. Using currentColor in the SVG with CSS color styling via JavaScript is a reliable cross-browser alternative. The example above works in modern browsers and the HA web app.


Shape Texture

shape_texture renders an SVG-native texture or animation inside the button shape fill — clipped to the shape boundary. Available in preset mode only. Elbow cards also support this feature.

yaml
shape_texture:
  preset: fluid
  opacity: 0.4            # 0–1, or state-based map
  mix_blend_mode: screen
  speed: 1.0              # 0 = static
  config: {}

Available Presets

PresetDescriptionKey Config
gridScrolling orthogonal grid linesline_spacing, pattern (both/horizontal/vertical)
diagonalScrolling diagonal hatchingline_spacing
hexagonalScrolling hexagonal gridhex_radius
dotsScrolling dot griddot_radius, spacing
fluidOrganic swirling fractalNoisebase_frequency, num_octaves
plasmaDual-colour turbulence washcolor_a, color_b, base_frequency
shimmerDirectional light-sweepangle, highlight_width, speed
flowDirectional streaming currentswave_scale, scroll_speed_x
levelFill bar with optional wavefill_pct, direction, wave_height
pulseBreathing radial glowradius, min_size, speed
scanlinesCRT-style scan-line overlayline_spacing, direction

All color fields accept var(--lcards-*), {theme:...}, rgba(), hex, or a state-based map.

For full parameter reference see Shape Texture System.


Background Animations

See Background Animations for full docs.

yaml
background_animation:
  - preset: grid
    config:
      line_spacing: 40
      color: "alpha(var(--lcards-orange), 0.3)"

Annotated Example

A lozenge button with entity binding, state-based colours, templates, an animation, and actions:

yaml
type: custom:lcards-button
entity: light.workbench
preset: lozenge

text:
  default:
    font_family: "Antonio, sans-serif"
  label:
    content: Workbench
    position: top-left
    font_size: 11
    text_transform: uppercase
    color: "var(--lcards-moonlight)"
  value:
    content: "[[[return entity.state === 'on' ? Math.round(entity.attributes.brightness / 255 * 100) + '%' : 'Off']]]"
    position: center
    font_size: 26
    font_weight: bold
    color:
      default: "var(--lcards-moonlight)"
      inactive: "var(--lcards-gray)"

icon: mdi:desk-lamp
icon_area: left
icon_style:
  color:
    default: "var(--lcards-gray)"
    active: "var(--lcards-orange)"
  size: 28

style:
  border:
    color:
      default: "var(--lcards-gray)"
      active: "var(--lcards-orange)"
    width: 2

tap_action:
  action: toggle

hold_action:
  action: more-info

animations:
  - trigger: on_tap
    preset: bounce
    params:
      scale_max: 1.05
      bounces: 2
    duration: 400

  - trigger: on_entity_change
    entity: light.workbench
    to_state: "on"
    check_on_load: true
    preset: glow
    params:
      color: "var(--lcards-orange)"
      blur_max: 12
    loop: true