Skip to content

Style, Text and Hover ​

How a button looks and reacts: its background and border, the text on it, what happens when the pointer is over it, and filters. Colours take a plain colour or a state map (default, active, inactive, unavailable, hover, pressed, exact states and ranges).

style.card ​

style.card.color.background is the button's fill colour, one colour or one per state. Use it to light a button when its entity is on and dim it when off.

  • hover and pressed keys colour the button while the pointer is over it or it is pressed. They have no effect when interactive is false.
yaml
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
  name:
    show: true
style:
  card:
    color:
      background:
        active: var(--lcars-orange)
        inactive: var(--lcars-gray)
        hover: var(--lcars-yellow)
tap_action:
  action: toggle
KeyTypeDefaultDescription
style.card.color.backgroundcolour / state mapfrom the preset (theme button colours)The button's fill

style.border ​

The border's colour, width and corner radius. Rounded presets set the radius for you; set it yourself for a custom shape.

  • width and radius take one number for every side or corner, or an object with one key per side (top, right, bottom, left) or corner (top_left, top_right, bottom_right, bottom_left). The sides or corners an object leaves out keep the preset's value.
  • A radius larger than half the button's height (or width) is made smaller to fit, so a tall button keeps its shape.
yaml
type: custom:lcards-button
entity: light.living_room
preset: outline
text:
  name:
    show: true
style:
  border:
    width: 3
    color:
      active: var(--lcars-orange)
      inactive: var(--lcars-gray)
    radius:
      top_left: 24
      bottom_right: 24
tap_action:
  action: toggle
More about style.border
  • Rounded presets: lozenge, bullet and capped take their round ends from the Home Assistant theme's card radius (--ha-card-border-radius, 34 px in HA-LCARS), not from the button's height.
  • Theme values: width and radius also take a theme token or a CSS variable, such as theme:components.button.radius.large or var(--ha-border-radius-lg).
KeyTypeDefaultDescription
style.border.colorcolour / state mapthe button's own colour (theme button colours)Border colour. It matches the fill by default, so on a filled preset set a different colour to see the border
style.border.widthnumber / string / objectfrom the preset: 0 on mostBorder width in px, a token, or one per side
style.border.width.topnumber / stringfrom the presetTop border width
style.border.width.rightnumber / stringfrom the presetRight border width
style.border.width.bottomnumber / stringfrom the presetBottom border width
style.border.width.leftnumber / stringfrom the presetLeft border width
style.border.radiusnumber / string / objectfrom the presetCorner radius in px (0 to 100), a token, or one per corner
style.border.radius.top_leftnumber / stringfrom the presetTop-left corner radius
style.border.radius.top_rightnumber / stringfrom the presetTop-right corner radius
style.border.radius.bottom_rightnumber / stringfrom the presetBottom-right corner radius
style.border.radius.bottom_leftnumber / stringfrom the presetBottom-left corner radius

Text Fields ​

text puts any number of labels on the button, each placed and styled on its own. The full reference is the Text Fields page.

  • Every preset already has three fields: name (the entity's name), state (its state) and label (a random code). Most presets hide them until you set show: true; fields with any other name show by default.
  • text.default sets the font, size and colour for every field on the card, and style.text.default does the same at a lower priority.
yaml
type: custom:lcards-button
entity: sensor.temperature
preset: barrel
text:
  default:
    font_family: "Antonio, sans-serif"
    color: var(--lcards-moonlight)
  name:
    content: TEMPERATURE
    show: true
    position: top-left
    font_size: 11
  value:
    content: "{entity.state}"
    position: center
    font_size: 28
    font_weight: bold
    color:
      default: var(--lcards-moonlight)
      unavailable: var(--lcars-alert-red)
grid_options:
  rows: 2
KeyTypeDefaultDescription
textobjectfrom the presetThe fields, keyed by any name you choose: see Text Fields
text.defaultobject-Font, size and colour for every field
style.text.default.colorcolour / state mapthe theme's button text colourText colour for every field, below text.default
style.text.default.font_sizenumber / stringfrom the presetFont size for every field
style.text.default.font_weightstring / numberfrom the presetFont weight for every field
style.text.default.font_familystringfrom the presetFont for every field
style.text.default.letter_spacingnumber / stringnormalSpace between letters for every field: px as a number, or a CSS value (0.1em)
style.text.default.text_transformstringfrom the presetCase for every field: none, uppercase, lowercase or capitalize

interactive ​

interactive: false makes a button decorative: no hand cursor, no hover colour, no hover animations. Use it for panels, headers and fillers that shouldn't look tappable.

  • A button with no action, no animation a pointer starts (on_tap, on_hover, ...) and no entity a tap can toggle (a title, a dot row, a filler, a sensor readout) is decorative already; set interactive: true to give it hover effects anyway.
  • A label bound to a light, switch or input boolean only for its text or colour still toggles it on a tap; give it tap_action: { action: none } and it is decorative too.
  • Taps and holds still run their actions, so a decorative button can still do something.
yaml
type: custom:lcards-button
entity: light.corridor
preset: lozenge
interactive: false # no hand cursor or hover colour
text:
  name:
    show: true
tap_action:
  action: toggle # still works
More about interactive
  • What changes: with interactive: true the cursor is a hand (pointer), the background changes to the hover colour from the preset or style, and hover animations run. With false the cursor is the arrow (default), the colour stays, and hover animations don't run.
  • Presets: the panel presets set interactive: false for you.
KeyTypeDefaultDescription
interactivebooleantrue with an action or a switchable entity, else false (false on panel presets)false: no hand cursor, hover colour or hover animations. Actions still run

style.cursor ​

style.cursor sets the mouse cursor over the button, whatever interactive says. Use it to keep the hover effects but show a different cursor.

yaml
type: custom:lcards-button
preset: lozenge
text:
  label:
    content: TARGET
    show: true
style:
  cursor: crosshair
KeyTypeDefaultDescription
style.cursorstringpointer, or default when interactive: falseAny CSS cursor: pointer, default, none, not-allowed, crosshair, grab, zoom-in, help, wait, progress, move, copy, text ...

filters ​

filters runs CSS or SVG filters over the whole button: blur, brightness, colour shifts, glows. They apply in order, the first innermost. The Filters page lists every type and its value.

yaml
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
  name:
    show: true
filters:
  - type: brightness
    value: 0.8
  - type: saturate
    value: 0.5
  - type: blur
    value: 1px
KeyTypeDefaultDescription
filters[].modestringcsscss for CSS filter functions, svg for SVG filter primitives
filters[].typestringrequiredA CSS filter (blur, brightness, contrast, saturate, drop-shadow ...) or an SVG primitive
filters[].valuestring / number / object-The filter's value: its form depends on the type (blur takes a length such as 4px)

Annotated Example ​

A lozenge with state colours, a templated value, an icon, actions and two animations. Each part is labelled.

yaml
type: custom:lcards-button
entity: light.workbench
preset: lozenge
grid_options:
  rows: 2
# text: a small name at the top left, the brightness in the middle
text:
  default:
    font_family: "Antonio, sans-serif"
  label:
    content: Workbench
    show: true
    position: top-left
    font_size: 14
    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: grey when off, orange when on
show_icon: true
icon: mdi:desk-lamp
icon_area: left
icon_style:
  color:
    default: var(--lcards-gray)
    active: var(--lcards-orange)
  size: 28
# border: orange when on
style:
  border:
    color:
      default: var(--lcards-gray)
      active: var(--lcards-orange)
    width: 2
# actions
tap_action:
  action: toggle
hold_action:
  action: more-info
# animations: a bounce on tap, a glow while the light is on
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
KeyTypeDefaultDescription
animationslist-Animations on triggers such as on_tap and on_entity_change: see Animations
tap_actionobject-What a tap does: see Actions
hold_actionobject-What a hold does
double_tap_actionobject-What a double tap does

Released under the MIT License. | About