šŸ”¹ Card-mod - Super-charge your themes!

Compact Header for card-mod

Iā€™m currently using the below card-mod code for my theme (since itā€™s slightly more compact than the native compact header for Home Assistant). Thereā€™s only one small issueā€¦ the microphone icon is a little too close to the 3 dots:

Could someone please let me know what I need to change to make the microphone icon and 3 dots icon spaced further apart?

  card-mod-theme: MyCustomTheme
  # Header
  card-mod-root-yaml: |
    paper-tabs$: |
      .not-visible {
        display: none;
      }
      /*Uncomment this if you want the header on the bottom
      #selectionBar {
        bottom: unset !important;
      }
      */
    ha-app-layout$: |
      /* This corrects top padding for the view. */
      #contentContainer {
        /* Change this to 0px if you want the header on the bottom */
        padding-top: 48px !important;
      }
    ha-button-menu$mwc-menu$mwc-menu-surface$: |
      .mdc-menu-surface {
        margin: 10px;
        box-shadow: var(--ha-card-box-shadow, 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12));
      }
    .: |
      /* This hides the unused portion of the header. */
      app-toolbar {
        height: 0;
      }
      /* This forces background-color and text-color. */
      .edit-mode, app-header, app-toolbar {
        background-color: var(--app-header-background-color) !important;
        color: var(--primary-text-color) !important;
      }
      /* Uncomment this if you want the header on the bottom
      app-header {
        top: calc(100vh - 60px) !important;
        bottom: 0 !important;
        transform: unset !important;
      }
      hui-masonry-view {
        padding-bottom: 60px !important;
      }
      */
      /* This gives the header in edit mode a different look from the standard header. */
      app-header.edit-mode {
        border-bottom: 2px var(--primary-color) solid;
        padding-bottom: 10px;
      }
      /* Make the color of the plus white instead of black. */
      #add-view ha-svg-icon {
        color: #EEE !important;
      }
      /* Bring voice button back down */
      app-toolbar:not([class="edit-mode"]) mwc-icon-button[label] {
        top: 0;
        right: calc(48px * 1);
        z-index: 2;
        position: absolute;
      }
      /* Bring help button back in */
      a[href="https://www.home-assistant.io/lovelace/"] > mwc-icon-button {
        right: calc(48px * 2);
        position: absolute;
        z-index: 2;
      }
      /* Bring close button back in */
      mwc-icon-button[title="Close"] {
        top: 0;
        left: 0;
        position: absolute;
        z-index: 2;
      }
      /* Bring add view button back in */
      mwc-icon-button#add-view {
        position: fixed;
        right: 48px;
      }
      /* Bring edit UI overflow menu back in */
      ha-button-menu {
        top: 0;
        right: 0;
        z-index: 2;
        position: absolute;
        /*Uncomment this out to hide the overflow menu
        display: none;
        */
      }
      /* Hide the title */
      app-toolbar > [main-title] {
        display: none;
      }
      /* Hide buttons that are taking up space, but invisible */
      menu-button[style="visibility: hidden;"] {
        display: none;
      }
      /* Bring sidebar button back in */
      ha-menu-button {
        z-index: 2;
        top: 24px;
      }
      /* Set margin on left to be smaller,
      and set the bar color to be the primary color
      instead of white */
      paper-tabs {
        --paper-tabs-selection-bar-color: var(--primary-color) !important;
        margin-left: 48px !important;
      }
      /* When not in edit mode, shrink the left margin */
      app-toolbar:not(.edit-mode) > div > paper-tabs {
        margin-left: 6px !important;
      }
      /* Color selected tabs */
      paper-tab[aria-selected="true"] > ha-icon {
        color: var(--primary-color) !important;
      }
      paper-tab[aria-selected="true"] {
        color: var(--primary-color) !important;
      }
      /* Styles for mobile */
      @media (orientation: portrait) {
        /* Hide sidebar button and keep room for the overflow menu button */
        paper-tabs {
          margin-left: 5px !important;
          margin-right: 48px !important;
        }
        /* Hide voice button */
        mwc-icon-button[label="Start conversation"] {
          display: none !important;
        }
        /* Hide sidebar button */
        ha-menu-button {
          display: none !important;
        }
      }
      /* Make help button have contrast */
      app-toolbar a {
        color: var(--primary-text-color) !important;
      }
  # Badges and columns
  card-mod-view-yaml: |
    hui-masonry-view$: |
      /*Uncomment this if you want the header on the bottom
      mwc-fab[title="Add Card"] {
        bottom: 96px !important;
      }
      */

What HA version are you using? If youā€™re using the latest version of HA, hereā€™s the latest version of the theme (scroll down to the :warning: sign): https://github.com/thomasloven/lovelace-card-mod/wiki/Theme-cookbook#compactcustom-header

Thank you. Iā€™m using the latest version Home Assistant 2021.1.4. That resolved the issue.

Does anyone know what code to use in order to add blur transparency effect to card-modā€™s compact header code using popup-background filter? ā€¦considering the below example would add transparency to dialog-related resources using card-mod in my custom theme. Iā€™m not very good with manipulating styles.

  card-mod-more-info-yaml: |
    $: |
      .mdc-dialog {
        backdrop-filter: blur(10px);
        background: rgba(0,0,0,0.0);
      }
      .mdc-dialog .mdc-dialog__container .mdc-dialog__surface {
        border-radius: 1em;
      }

Below, is the code I tried to add to my theme. which is obviously wrong:

  card-mod-more-info-yaml: |
    $: |
      app-header, app-toolbar {
        backdrop-filter: blur(5px);
        background: rgba(0,0,0,0.32);
      }

I donā€™t think you could style another element based off another item.

1 Like

Thank you for confirming.

Even though you canā€™t style the Lovelace header, you can style the dialog. Could you provide a mockup?

Sorry @KTibow , I have no idea what ā€œstyle the dialogā€ means. Are you saying itā€™s still possible to ultimately add a transparency blur effect to the header? If so, do you mind giving me another hint what I need to do?

The header in the more info dialog is not called app-header or app-toolbar.

Man, I think this is way over my head. Iā€™m not even sure where the more info dialog is. I just wanted to know how to add a blur effect to the below header, if possible.

So if Iā€™m right, when a dialog is open, you want to blur the header in the background but nothing else?

I finally understood what you were trying to tell me earlier. It doesnā€™t appear that itā€™s possible to use the blur backdrop filter on the header itself. I was hoping there might still be a way to manipulate the blur filter to add blur transparency to the header (even though it wasnā€™t intended for that).

BTW: I already have the blur effect enabled for all possible popups/dialogs in Home Assistant by adding the below code to my theme:

dialog-backdrop-filter: blur(5px)
iron-overlay-backdrop-opacity: 1
iron-overlay-backdrop-background-color: rgba(0, 0, 0, 0.32)

I really do appreciate your effort to help out. Thank you for your time.

PS: Below, is what the header looks like if I use regular transparency to the header without blur; which doesnā€™t look very good:

Oh! I get what you mean! Change this:

      /* Let's change the background. */
      app-header, app-toolbar {
        background: var(--primary-background-color) !important;
        color: var(--primary-text-color) !important;
      }

to this:

      /* Let's change the background. */
      app-header, app-toolbar {
        background: var(--primary-background-color) !important;
        backdrop-filter: blur(10px);
        color: var(--primary-text-color) !important;
      }

Hopefully that works.

Unfortunately, it didnā€™t make any difference when I inserted that extra ā€œbackdrop-filter:ā€ line. I guess the backdrop-filter wasnā€™t meant to be used for anything except for popup/backdrops. Oh well. It was worth a shot. Thanks.

Hi,

i am using card-mod-view to change the style of the masonry and panel views.

  card-mod-view-yaml: |  
    hui-masonry-view$: |
      .column {
        max-width: 580px!important;
      }  
      
    hui-panel-view$:
      hui-vertical-stack-card$: |
        #root {
          margin: 20px!important;
        }      

Individually they both work, but together in the same theme they donā€™t, only the first block works.

How can I do?
Thanks!

Thatā€™s not a panel view, thatā€™s a vertical stack card.

@KTibow Yes I know. The first vertical-stack inside a panel view. Thatā€™s how I need it and it works.

The problem is another. It seems that under card-mod-view-yaml it is possible to put only one block

@thomasloven any suggestions?

Usually the original maintainer is unresponsive here. You could try to apply the vertical-stack styling by putting it in a mod-card, and shadow-rooting there.

@KTibow but i would like to know why i canā€™t apply two different styles below card-mod-view-yaml: