Fonts, Colour and Backgrounds
How a text field looks: its font, sizing it to fill its zone, its colour, and the box behind a bar label. Every key here also works in text.default, so a whole card can share one style. The other field keys are on the Text Fields page.
Fonts
The font, size, weight, case and letter spacing of a field. Set them in text.default for the whole card, and on a field where it differs.
- The button presets set the theme's LCARS font in upper case, so lower case needs
text_transform: none. font_sizein pixels stays the same however big the card is. To scale text with the card, usefont_size_percent.
type: custom:lcards-button
preset: lozenge
text:
default:
color: var(--lcars-black)
title:
content: Shuttle bay
position: top-left
font_size: 18
font_weight: bold
text_transform: uppercase
letter_spacing: 3
sub:
content: Doors sealed
position: bottom-left
font_size: 12
font_family: "Antonio, sans-serif"
text_transform: none
grid_options:
rows: 2| Key | Type | Default | Description |
|---|---|---|---|
font_size | number / string | the preset's, else 14 | Size in px (1 to 200), or a CSS size such as 14px or 1.2rem |
font_family | string | the theme's font (LCARS, Antonio) | A CSS font family or stack, such as "Antonio, sans-serif" or var(--lcars-font) |
font_weight | string / number | normal | normal, bold, or 100 to 900. The bar-label presets use 100 |
text_transform | string | none; uppercase in the button presets | none, uppercase, lowercase or capitalize |
letter_spacing | number / string | normal | Space between letters: px as a number (2), or a CSS value (0.1em, 2px) |
Filling a zone
font_size_percent sizes text to its zone's height, and stretch spreads it across the zone's width. Text sized this way grows and shrinks with the card, which is how the bar-label presets fill their bar.
font_size_percent: 100makes the capital letters fill the zone's height;50fills half of it. Use it instead offont_size, not with it.stretchspaces and widens the letters to fill a share of the zone's width:trueis all of it,0.8is 80 %. Height and width are independent, so the two keys work together.cap_height_ratiotells LCARdS how tall a font's capitals are, as a share of its size. The theme's0.86is right for Antonio; set it for another font so100still fills the zone exactly.
type: custom:lcards-button
preset: lozenge
text:
title:
content: WARP CORE
position: center
font_size_percent: 60 # capitals 60 % of the height
stretch: 0.8 # letters spread over 80 % of the width
color: var(--lcars-black)
grid_options:
rows: 2More about filling a zone
- Centred positions: the capitals fill exactly the percentage on the
center,center-leftandcenter-rightpositions, measured inside the top and bottom padding. On the top and bottom positions the font size is that percentage of the zone's height. - Without a ratio: with no
cap_height_ratiofrom the field, the preset or the theme, the font size itself is the percentage of the zone, so capitals come out a little smaller. The elbow uses0.87then. - Stretch and position: on a button with a component, stretched text starts at the left padding and fills the zone's width inside the padding. Elsewhere it spreads from its point to the share of the zone's whole width, so it fits best with
position: center.
| Key | Type | Default | Description |
|---|---|---|---|
font_size_percent | number | - | Font size as a percentage of the zone's height, 1 to 100 |
cap_height_ratio | number | 0.86, from the theme | Height of the font's capitals as a share of its size, 0.1 to 1.0. 1.0 means no correction |
stretch | boolean / number | - | Fill a share of the zone's width: true for all of it, or a fraction from 0 to 1 |
fit
fit keeps a long text inside its zone: it shrinks the text first, wraps it onto a second line if shrinking is not enough, and ends it with an ellipsis as a last resort. Use it for names you don't control, such as an entity's name in a small block or a gauge cap.
fit: trueuses the defaults: down to 60 % of the font size (not below 8), two lines, then an ellipsis. Give an object to set your own limits.- Text that already fits keeps its size, so
fitchanges nothing until the content is too long. - The width is the room from the text's position to the zone's edge (both edges for centred text), inside the padding; wrapped lines stay round the position, within the zone's height.
type: custom:lcards-layout-card
layout:
height: 64px
grid-gap: 6px
grid-template-columns: repeat(3, 120px)
grid-template-rows: 48px
cards:
# too long: runs out of the block
- type: custom:lcards-button
preset: panel-light
min_height: 0
text:
label:
content: PRIMARY SYSTEMS DISPLAY
position: center-right
font_size: 20
# shrinks, then wraps
- type: custom:lcards-button
preset: panel-light
min_height: 0
text:
label:
content: PRIMARY SYSTEMS DISPLAY
position: center-right
font_size: 20
fit: true
# one line only: shrinks, then the ellipsis
- type: custom:lcards-button
preset: panel-light
min_height: 0
text:
label:
content: PRIMARY SYSTEMS DISPLAY
position: center-right
font_size: 20
fit:
max_lines: 1
min_font_size: 14More about fit
- With stretch:
stretchalready sets the width, so a field withstretchignoresfit. - Component zones: in a component's zone (a gauge cap, the D-pad) the sizes are in the component's own units, like its
font_size. - Sizes in CSS: a
font_sizethat isn't a number (avar()orclamp()) can't be measured, so the text is drawn as it is.
| Key | Type | Default | Description |
|---|---|---|---|
fit | boolean / object | - | true to fit with the defaults, or an object with the limits below |
fit.min_font_size | number | 60 % of font_size, at least 8 | The smallest size the text shrinks to |
fit.max_lines | integer | 2 | The most lines it wraps to, at spaces; 1 shrinks only |
fit.overflow | string | ellipsis | Text still too long at the smallest size: ellipsis ends it with …, clip cuts it |
color
The text colour: one colour, or a map that picks one by the entity's state. A map makes a value turn red when the entity is unavailable, or bright when a light is on.
- The map's keys are the state colour keys:
default,active,inactive,unavailableand the others. - A colour set on the field or in
text.defaultwins over the preset's text colour.
type: custom:lcards-button
entity: light.kitchen
preset: lozenge
text:
status:
content: "{entity.state}"
show: true
position: center
font_size: 22
color:
default: var(--lcards-moonlight)
active: var(--lcars-orange)
inactive: var(--lcars-gray)
unavailable: var(--lcars-alert-red)
grid_options:
rows: 2| Key | Type | Default | Description |
|---|---|---|---|
color | colour / state map | the theme's text colour for the state | A colour, or a state map of colours |
Text background
A box behind the text, the classic LCARS bar break: the label sits in a gap in a coloured bar. The bar-label presets use it with a black box.
- The box is as tall as the zone and as wide as the text plus
background_paddingon each side. backgroundtakes a colour or a state map, ascolordoes.
type: custom:lcards-button
entity: light.kitchen
preset: bar-label-left
text:
label:
show: true
content: Kitchen lights
background:
default: var(--lcars-black)
active: var(--lcars-blue)
background_padding: 20More about the text background
- Presets: the bar-label presets set a black box,
background_padding: 15andbackground_radius: 0. - Fixed width and anchor: with
background_widthset,background_paddingno longer sets the box's width, but it still sets how far the text sits from the box's anchored edge. Extra space goes to the other side, so withanchor: endthe right edge stays put and the box grows to the left. - Components: text on a button with a
componenthas no background box.
| Key | Type | Default | Description |
|---|---|---|---|
background | colour / state map | - | Box colour, by state if you like |
background_padding | number | 8 | Space between the text and the box's left and right edges, px |
background_radius | number | 4 | Corner radius, px. 0 is square |
background_width | number | as wide as the text | A fixed width, px. Longer text runs past the box |
background_min_width | number | - | The narrowest the box gets, px. It still grows with longer text |
Aligning stacked cards
background_min_width gives the boxes on a stack of bar-label cards the same width, so their edges line up. Each box would otherwise be as wide as its own text.
background_min_widthis safe for values that change length;background_widthpins an exact width.
type: custom:lcards-button
entity: sensor.power
preset: bar-label-right
text:
label:
show: true
content: "[[[return entity.state + ' W']]]"
background_min_width: 120 # every card in the stack uses the same value