card-mod ======== [![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs) ## Requires Home Assistant version 0.98 or later Allows you to add css styles to any lovelace card. For installation instructions [see this guide](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins). Install `card-mod.js` as a `module`. ## Usage This is *not* a new card. Instead it *changes the way pretty much any other card works*. Specifically, it looks for `style:` in any cards configuration, and applies the [CSS](https://www.w3schools.com/css/) specified there to the card. The basis of almost all lovelace cards is a `ha-card` element, so that's probably where you'd want to start. Note that some cards (`conditional`, `entity-filter`, `horizontal-stack` and `vertical-stack` as well as some custom cards, like `layout-card`, `auto-entities` and `state-switch` among others) do *not* have a `ha-card` element, and `card-mod` will thus **not** work for those. There is a workaround, though. See FAQ below. --- **Example:**\ Change the text color of an `entities` card to red. ```yaml type: entities style: | ha-card { color: red; } entities: - light.bed_light - light.ceiling_lights - light.kitchen_lights ``` ![red text](https://user-images.githubusercontent.com/1299821/59151548-38a8d800-8a35-11e9-875a-64e72fd6f5a6.png) --- By using the element inspector of your browser ([chrome](https://developers.google.com/web/tools/chrome-devtools/inspect-styles/), [firefox](https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Open_the_Inspector), [safari](https://discussions.apple.com/thread/5508711), [explorer](https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/samples/gg589500(v=vs.85))) you can find out how cards are built up and what styles they are using. **Example** \ Make a `glance` card use smallcaps and change the font size of the title ```yaml type: entities style: | ha-card { font-variant: small-caps; } .card-header { font-size: 16px; } entities: - light.bed_light - light.ceiling_lights - light.kitchen_lights ``` ![smallcaps](https://user-images.githubusercontent.com/1299821/59151624-9a1d7680-8a36-11e9-9b2d-598c80ff2aa1.png) You can also use [templating](https://www.home-assistant.io/docs/configuration/templating/) to change the styles dynamically. **Example** \ Make an `entity-button` card green when the light is on ```yaml type: entity-button entity: light.bed_light style: | ha-card { background: {% if is_state('light.bed_light', 'on') %} green {% endif %}; } ``` ![templates](https://user-images.githubusercontent.com/1299821/59151667-45c6c680-8a37-11e9-819a-ae5a058ac069.png) Anything you add in `style:` will be put in a `