Card Styles
The style: block sets how a button looks: its background, its border and its corners. Start from a preset for the shape, then set only what you want to change.
- These keys are the button's. The select menu takes the same keys for its option buttons; the slider, elbow and other cards have their own style keys on their pages.
- Every colour takes one colour or a state map with one colour per state (
default,active,inactive,unavailable,hover,pressed, exact states and ranges). - Rules can change any style value while the dashboard runs.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
style:
card:
color:
background:
default: var(--lcards-orange)
inactive: var(--lcards-gray-dark)
border:
color: var(--lcards-blue)
width: 2
radius: 8
tap_action:
action: togglestyle.card
style.card.color.background is the card'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.
- A single colour (
background: var(--lcards-orange)) is used in every state. - In a state map,
activeis used while the entity is on,inactivewhile it is off andunavailablewhen Home Assistant cannot reach it;defaultis the fallback when no other key matches. hoverandpressedcolour the button while the pointer is over it or it is pressed. They have no effect wheninteractiveisfalse.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
style:
card:
color:
background:
default: var(--lcards-orange)
active: var(--lcards-orange)
inactive: var(--lcards-gray-dark)
unavailable: var(--lcards-gray-darkest)
hover: var(--lcards-orange-light)
pressed: var(--lcards-orange-dark)
tap_action:
action: toggleMore about style.card
- Colour formats: CSS variables,
theme:token paths, colour functions, hex and the other formats on the Colours page all work, on their own or as values in a state map.
| Key | Type | Default | Description |
|---|---|---|---|
style.card.color.background | colour / state map | from the preset (theme button colours) | The card'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.
widthandradiustake 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.- The border colour takes a state map like the background, so a border can light up when the entity is on.
- A radius larger than half the button's height (or width) is made smaller to fit, so a tall button keeps its shape.
type: custom:lcards-button
entity: light.living_room
preset: outline
text:
name:
show: true
style:
border:
width: 3
color:
default: var(--lcards-gray)
active: var(--lcards-orange)
inactive: var(--lcards-gray-dark)
radius:
top_left: 12
top_right: 12
bottom_right: 4
bottom_left: 4
tap_action:
action: toggleMore about style.border
- Without a preset: a button with no
presetdraws a2px border with20px corners unless you set them. - Theme values:
widthandradiusalso take a CSS variable, such asvar(--ha-border-radius-lg).
| Key | Type | Default | Description |
|---|---|---|---|
style.border.color | colour / state map | the 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.width | number / string / object | from the preset: 0 on most | Border width in px, a token, or one per side |
style.border.width.top | number / string | from the preset | Top border width |
style.border.width.right | number / string | from the preset | Right border width |
style.border.width.bottom | number / string | from the preset | Bottom border width |
style.border.width.left | number / string | from the preset | Left border width |
style.border.radius | number / string / object | from the preset | Corner radius in px (0 to 100), a CSS variable, or one per corner |
style.border.radius.top_left | number / string | from the preset | Top-left corner radius |
style.border.radius.top_right | number / string | from the preset | Top-right corner radius |
style.border.radius.bottom_right | number / string | from the preset | Bottom-right corner radius |
style.border.radius.bottom_left | number / string | from the preset | Bottom-left corner radius |
icon_style
The icon's colour and size are set in icon_style, at the top level of the card, not inside style:. The icon shows when show_icon is true, and its colour can follow the entity's state like the background.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
show_icon: true
icon: mdi:lightbulb
text:
name:
show: true
icon_style:
size: 28
color:
active: var(--lcards-yellow)
inactive: var(--lcards-gray)
tap_action:
action: toggle| Key | Type | Default | Description |
|---|---|---|---|
icon_style.color | colour / state map | the preset's icon colour | Icon colour |
icon_style.size | number | 24 | Icon size, 8 to 200 px |
| All icon keys | Position, rotation, padding and spacing, on the button's Icons page |
Dimensions
The card's size is set at the top level of the card, not inside style:. By default a card is as big as its cell; set a size for a fixed card or for one outside a sections grid.
- A number is pixels (
200is200px); a string takes any CSS length, such as50%or10vh. min_heightis a floor for a card that sizes itself. Whenheightis set too, the card is exactlyheighttall andmin_heightis ignored.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
width: 200
height: 48
text:
name:
show: true
tap_action:
action: toggle| Key | Type | Default | Description |
|---|---|---|---|
width | number / string | the cell's width | Card width: a number is px, or any CSS length |
height | number / string | the cell's height | Card height: a number is px, or any CSS length |
min_height | number / string | the button's preset: the theme's button height | Smallest height (a number is px). Ignored when height is set |
| More sizing keys | min_width, max_height, max_width and how sizes work in a sections grid |
Interaction with Presets and Rules
A card's look is built in layers, and each layer wins over the one before it. You only set the values that differ from the preset; anything you leave out comes from the layer below.
- The layers, lowest first: LCARdS and theme defaults, the preset, your
style:block, then rule patches while the dashboard runs. - To see which layer set each value, open the card editor's Main Engineering tab and its Provenance panel.
# The preset gives the shape and colours, the style block makes it blue,
# and a rule turns it red while the kitchen light is on (tap to toggle)
type: custom:lcards-button
entity: light.kitchen
preset: lozenge
id: layered-btn
text:
name:
content: LAYERS
show: true
style:
card:
color:
background: var(--lcards-blue)
rules:
- id: layered-red
when:
entity: light.kitchen
state: "on"
apply:
overlays:
layered-btn:
style:
card:
color:
background: var(--lcars-red)
tap_action:
action: toggleRelated
- Presets: named style collections for quick setup
- Colours: accepted colour formats, theme tokens, state maps
- Rules Engine: how style patches are applied at runtime
- Main Engineering: inspect runtime effective config per card
- Button styles: text fields, hover, the cursor and filters on a button