lovelace-card-mod icon indicating copy to clipboard operation
lovelace-card-mod copied to clipboard

Detecting Dark Mode

Open fusionstream opened this issue 3 years ago • 4 comments
trafficstars

Would be cool to be able to detect dark mode. That way one can have separate color palettes for light and dark mode

fusionstream avatar Feb 23 '22 05:02 fusionstream

...or you can define different variables in your themes instantly:

my_theme:

  modes:
    light:
      user-bar-card-fill-color: red
      ...

    dark:
      user-bar-card-fill-color: green
      ...

ildar170975 avatar Feb 23 '22 13:02 ildar170975

Sorry should have been clearer. Am not using themes. Stock light and dark mode.

fusionstream avatar Feb 23 '22 17:02 fusionstream

Did you try the new CSS media selectors? https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/

berrywhite96 avatar Mar 19 '22 20:03 berrywhite96

Did you try the new CSS media selectors?

Success!

type: entities
entities:
  - entity: sun.sun
    name: cyan if DARK
    card_mod:
      style:
        hui-generic-entity-row $: |
          @media (prefers-color-scheme: dark) {
            state-badge {color: cyan;}
          }
          @media (prefers-color-scheme: light) {
            state-badge {color: red;}
          }

Described here: https://community.home-assistant.io/t/card-mod-add-css-styles-to-any-lovelace-card/120744/3017

ildar170975 avatar Mar 19 '22 22:03 ildar170975