Filters
Filters change how a whole card looks: blur it, brighten it, take the colour out, tint it, give it a shadow or warp it. Stack several in a list to combine them.
filtersworks on the button and elbow cards, and on the data grid with CSS filters only. The MSD card has the same filters for its blueprint asbase_svg.filters(Base SVG Filters).- There are two kinds: the browser's CSS filters, which most looks need, and SVG filter primitives for what CSS can't do, such as a real colour tint or a distortion.
filters
filters is a list of filters applied to the card, one after another. Each entry names a type and gives its value; SVG filters also need mode: svg.
- The CSS filters run first, in list order, then the SVG filters, chained in list order. Where you put an SVG entry among the CSS ones makes no difference.
- On the button and elbow the filters apply to the card's drawing (its SVG), so the shape, its text and its icon change together.
- An SVG type written without
mode: svgis read as a CSS filter, which doesn't exist, so it is skipped (with a warning in the browser console).
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
# softened and brighter
filters:
- type: blur
value: 1px
- type: brightness
value: 1.3More about filters
- Live values: filter values are fixed; templates and entity bindings don't work in them.
- Data grid: the grid takes CSS filters only. SVG filters need an SVG to attach to, so the grid skips them and logs a warning.
| Key | Type | Default | Description |
|---|---|---|---|
filters | list | - | The filters, applied in order |
filters[].type | string | required | The filter: one of the CSS filters or SVG filters |
filters[].value | number / string / object | per type | A number or string for a CSS filter, an object of value keys for an SVG filter |
filters[].mode | string | css | css or svg. Set svg for the SVG filters |
CSS Filters
The browser's own CSS filters: blur, brighten, change the contrast or saturation, shift the hues, fade or turn the card grey. Leave out mode (or write mode: css); most take one number as value.
blurtakes a length andhue-rotatean angle, as strings with their unit ("4px","90deg").- Every CSS entry needs a valid
value. One without avalue, or ablurwithoutpx, makes the browser drop the CSS filters of the whole list, not just that entry. - Each filter has a playground under the example: move the sliders to see it on a sample shape, and copy the YAML it prints.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
# faded colours, a little darker, slightly soft
filters:
- type: saturate
value: 0.4
- type: brightness
value: 0.85
- type: blur
value: 1pxTry each CSS filter
The playgrounds run the real filter code on a sample shape.
blur
Loading live preview…
brightness
Loading live preview…
contrast
Loading live preview…
saturate
Loading live preview…
hue-rotate
Loading live preview…
grayscale
Loading live preview…
sepia
Loading live preview…
invert
Loading live preview…
opacity
Loading live preview…
drop-shadow
Loading live preview…
type | value | Example | Effect |
|---|---|---|---|
blur | string, px | "4px" | Gaussian blur; "0px" is none |
brightness | number | 1.4 | 0 is black, 1 unchanged, above 1 brighter |
contrast | number | 1.2 | 0 is grey, 1 unchanged, above 1 more contrast |
saturate | number | 0.5 | 0 is grey, 1 unchanged, above 1 stronger colour |
hue-rotate | string, deg | "90deg" | Turns every hue round the colour wheel; "0deg" is none |
grayscale | number, 0 to 1 | 1 | 1 is fully grey, 0 none |
sepia | number, 0 to 1 | 0.6 | 1 is full sepia, 0 none |
invert | number, 0 to 1 | 1 | 1 inverts the colours fully, 0 none |
opacity | number, 0 to 1 | 0.5 | How see-through the card is; 1 is solid. For a see-through background only, use the background colour's alpha (style.card.color.background) |
drop-shadow | object | see below | A shadow outside the shape |
drop-shadow
A shadow behind the card's shape, for depth or a glow. The shadow follows the drawn shape, not the card's box.
xandyare numbers in px;bluris a length string such as"6px".- The colour goes straight into CSS, so
var(--lcars-*)variables and CSS colours work, buttheme:tokens andalpha()don't.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
filters:
- type: drop-shadow
value:
x: 2
"y": 2
blur: 6px
color: var(--lcars-orange)More about drop-shadow
- Short form:
valuecan also be the CSS shadow as one string, such as"2px 2px 6px black". The card reads it, but the config checker and the editor expect the object.
| Key | Type | Default | Description |
|---|---|---|---|
value.x | number | 0 | Offset to the right, px (negative is left) |
value.y | number | 0 | Offset down, px (negative is up) |
value.blur | string | 0px | Blur radius, such as "6px" |
value.color | colour | black | Shadow colour: a CSS colour or var(--lcars-*) |
SVG Filters
SVG filter primitives, for effects the CSS filters can't give: a real colour tint, colour matrices, glows, outlines and distortion. Each entry needs mode: svg, and its value is an object of value keys.
- They chain: each primitive works on the result of the one before it in the list, so a blur followed by a blend makes a glow.
tintis the friendly one: a single entry for a colour wash. The others are the browser's SVG primitives, named as in SVG (feGaussianBlur...).- The filter area reaches half the card's size past each edge, so a glow, shadow or warp has room outside the shape.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
# a soft glow: blur the card, then blend the blur back over it
filters:
- mode: svg
type: feGaussianBlur
value:
stdDeviation: 4
- mode: svg
type: feBlend
value:
mode: screenTry each SVG filter
The playgrounds run the real filter code on a sample shape.
feGaussianBlur
Loading live preview…
feColorMatrix
Loading live preview…
feOffset
Loading live preview…
feBlend
Loading live preview…
feComposite
Loading live preview…
feMorphology
Loading live preview…
feTurbulence
Loading live preview…
feDisplacementMap
Loading live preview…
On its own feDisplacementMap has nothing to warp by, so this playground may look unchanged. Chain it after feTurbulence in a real config to see the distortion.
tint
Loading live preview…
type | Value keys | Effect |
|---|---|---|
feGaussianBlur | stdDeviation | Gaussian blur that chains with the other SVG filters; smoother than the CSS blur |
feColorMatrix | type, values | Colour changes: saturation, hue turn, luminance to alpha or a custom matrix |
feOffset | dx, dy | Shifts the result; with a blur, makes a shadow |
feBlend | mode, in2 | Blends the result with the card (or another input) in a CSS blend mode |
feComposite | operator, k1 to k4, in2 | Combines the result with the card (or another input) |
feMorphology | operator, radius | Thins (erode) or thickens (dilate) the shapes |
feTurbulence | type, baseFrequency, numOctaves, seed | Makes a noise texture, usually for feDisplacementMap |
feDisplacementMap | scale, xChannelSelector, yChannelSelector, in, in2 | Warps the card by the colours of the result before it |
tint | color | A flat colour wash over the card, such as an alert tint |
SVG Value Keys
The keys each SVG filter takes in its value; a key you leave out takes the default in the table. Inputs name what a primitive works on: SourceGraphic (the card as drawn), SourceAlpha (its shape only), or the result of the primitive before.
feBlendandfeCompositecombine the previous result (on top) within2, which is the card itself unless you set it.feDisplacementMapwarpsin(the card) byin2(the previous result, such asfeTurbulencenoise).feTurbulencemakes new content and ignores what came before it.tintstarts from a flat colour and lays it over the card, so SVG filters listed before atinthave no effect. Its wash covers the whole filter area, background included, not only the shape.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
# noise, then warp the card by it
filters:
- mode: svg
type: feTurbulence
value:
baseFrequency: 0.04
numOctaves: 2
seed: 5
- mode: svg
type: feDisplacementMap
value:
scale: 8
xChannelSelector: R
yChannelSelector: GMore about the SVG value keys
- Colour matrix values: with
type: saturate,valuesis a multiplier (0grey,1unchanged); withtype: hueRotate, an angle in degrees; withtype: matrix, 20 numbers (a 4x5 matrix) as a list or a space-separated string.luminanceToAlphatakes novalues. - Arithmetic composite: with
operator: arithmetic, the result isk1*i1*i2 + k2*i1 + k3*i2 + k4, wherei1is the previous result andi2isin2. - Tint colour:
tint'scolortakes any LCARdS colour,theme:tokens andalpha()included; its alpha sets how much of the card shows through.
| Key | Type | Default | Description |
|---|---|---|---|
stdDeviation | number | 0 | feGaussianBlur: amount of blur |
type | string | saturate | feColorMatrix: saturate, hueRotate, luminanceToAlpha or matrix |
values | number / string / list | 1 saturate, 0 hueRotate | feColorMatrix: meaning depends on type; see the details above |
dx | number | 0 | feOffset: shift right, px (negative is left) |
dy | number | 0 | feOffset: shift down, px (negative is up) |
mode | string | normal | feBlend: normal, multiply, screen, darken, lighten, overlay, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color or luminosity |
operator | string | over | feComposite: over, in, out, atop, xor or arithmetic |
k1 | number | 0 | feComposite: arithmetic coefficient, only with operator: arithmetic |
k2 | number | 0 | feComposite: arithmetic coefficient, only with operator: arithmetic |
k3 | number | 0 | feComposite: arithmetic coefficient, only with operator: arithmetic |
k4 | number | 0 | feComposite: arithmetic coefficient, only with operator: arithmetic |
in2 | string | SourceGraphic | feBlend, feComposite: the second input |
operator | string | erode | feMorphology: erode (thinner) or dilate (thicker) |
radius | number | 1 | feMorphology: how far to thin or thicken |
type | string | turbulence | feTurbulence: turbulence (cloudy) or fractalNoise (softer) |
baseFrequency | number | 0.05 | feTurbulence: 0 to 1; lower is larger features |
numOctaves | integer | 1 | feTurbulence: 1 to 10 layers of detail |
seed | number | 0 | feTurbulence: change it for a different pattern |
scale | number | 10 | feDisplacementMap: how strong the distortion is |
xChannelSelector | string | R | feDisplacementMap: the channel that moves pixels across: R, G, B or A |
yChannelSelector | string | G | feDisplacementMap: the channel that moves pixels up and down |
in | string | SourceGraphic | feDisplacementMap: the image it warps |
in2 | string | the previous result | feDisplacementMap: the map it warps by |
color | colour | rgba(0,0,0,0.5) | tint: the wash colour, with its alpha |
Mixing CSS and SVG Filters
CSS and SVG filters can share one list. The CSS filters are applied first, in their order, then the SVG filters as one chain, whatever order the entries are in.
type: custom:lcards-button
entity: light.living_room
preset: lozenge
text:
name:
show: true
filters:
# CSS
- type: brightness
value: 1.2
# SVG
- mode: svg
type: feColorMatrix
value:
type: saturate
values: 0.6Related
- Base SVG Filters: the same filters on an MSD card's blueprint, with recipes and rules that change them on a condition
- Animations: animate a card over time; the
pulsepreset animates a brightness filter - Styles: card background and border styles
- Background Animations: canvas-based animated backgrounds (separate from filters)