Skip to content

Filters

LCARdS cards support stackable CSS and SVG visual filters applied directly to the card's rendered output. Combine multiple filters in any order to create blur, glow, colour shift, grain, or displacement effects.


Basic Usage

filters is a top-level card property. It takes an array of filter objects:

yaml
type: custom:lcards-button
entity: light.living_room
filters:
  - type: blur
    value: 3px
  - type: brightness
    value: 1.3

Filters are applied in order — first filter is innermost.


Filter Object Structure

FieldTypeDefaultDescription
typestringFilter type (required) — see tables below
valuestring / number / objectFilter value — format depends on type
modestringcsscss for CSS filter functions, svg for SVG filter primitives

CSS Filters (mode: css or omitted)

CSS filters map to standard CSS filter functions. They are simple, performant, and suitable for most visual effects.

typevalue formatExampleEffect
blur"Npx""4px"Gaussian blur
brightnessnumber (multiplier)1.4Increase / decrease brightness
contrastnumber (multiplier)1.2Increase / decrease contrast
saturatenumber (multiplier)0.5Increase / decrease colour saturation
hue-rotate"Ndeg""90deg"Rotate all hues by N degrees
grayscalenumber (0–1)1Full grayscale at 1, none at 0
sepianumber (0–1)0.6Sepia tint
invertnumber (0–1)1Full colour inversion at 1
opacitynumber (0–1)0.5Transparency (prefer style.card.color.background alpha for most uses)
drop-shadowobject or stringsee belowDrop shadow outside the shape

drop-shadow value

yaml
filters:
  - type: drop-shadow
    value:
      x: 2px
      y: 2px
      blur: 6px
      color: "rgba(255, 100, 0, 0.6)"

Or as a shorthand string:

yaml
filters:
  - type: drop-shadow
    value: "2px 2px 6px rgba(255, 100, 0, 0.6)"

Stacked CSS example

yaml
filters:
  - type: saturate
    value: 0.4
  - type: brightness
    value: 0.85
  - type: blur
    value: 1px

SVG Filters (mode: svg)

SVG filters use the browser's SVG filter pipeline and support compositing, displacement, turbulence, and colour matrix operations. More powerful than CSS filters — use when CSS isn't sufficient.

Multiple SVG filter primitives in the same filters: array are chained in sequence (output of each becomes input to the next).

typevalue fieldsEffect
feGaussianBlurstdDeviation (number)Gaussian blur (SVG quality)
feColorMatrixtype (saturate / hueRotate / matrix / luminanceToAlpha), valuesColour transformations
feOffsetdx, dy (numbers)Shift the image — use before feBlend for shadow effects
feBlendmode (normal / multiply / screen / overlay / etc.), in2Blend two layers
feCompositeoperator (over / in / out / arithmetic), plus k1–k4 for arithmeticComposite two layers
feMorphologyoperator (erode / dilate), radiusShrink or grow shapes
feTurbulencetype (turbulence / fractalNoise), baseFrequency, numOctaves, seedGenerate noise texture
feDisplacementMapscale, xChannelSelector, yChannelSelector, in2Distort using a displacement map

SVG examples

yaml
# Subtle colour shift
filters:
  - mode: svg
    type: feColorMatrix
    value:
      type: hueRotate
      values: 45

# Noise-based distortion (combine with feDisplacementMap)
filters:
  - mode: svg
    type: feTurbulence
    value:
      baseFrequency: 0.04
      numOctaves: 2
      seed: 5
  - mode: svg
    type: feDisplacementMap
    value:
      scale: 8
      xChannelSelector: R
      yChannelSelector: G

Mixing CSS and SVG Filters

CSS and SVG filters in the same filters: array are applied separately and composited together. CSS filters are collected and applied as a single CSS filter property; SVG filters are assembled into an inline <filter> element.

yaml
filters:
  - type: brightness       # CSS
    value: 1.2
  - mode: svg              # SVG
    type: feColorMatrix
    value:
      type: saturate
      values: 0.6

  • Animations — animate CSS filter values over time using the pulse or custom anime.js presets
  • Styles — card background and border styles
  • Background Animations — canvas-based animated backgrounds (separate from filters)