Sidebar card [WIP]

August 7, 2025 · View on GitHub

hacs_badge     GitHub release (latest by date)

Sidebar card [WIP]

This card adds a sidebar to your interface which you can configure globally so every page has the sidebar. It can replace your top navigation but can also give extra functionality.

Buy Me A Coffee

Installation Instructions

HACS Installation

Go to the hacs store and use the repo url https://github.com/DBuit/sidebar-card and add this as a custom repository under settings.

In Home Assistant's global settings, add the resource:

  1. Go to Settings → Dashboards → Three-dots menu → Resources in the top right
  2. Click + Add Resource button in the bottom right
  3. Enter in the following:
    • URL: /hacsfiles/sidebar-card/sidebar-card.js
    • Resource Type: JavaScript Module
  4. Click Create

Manual Installation

Copy the .js file from the dist directory to your www directory and add the following to your ui-lovelace.yaml file:

resources:
  url: /local/sidebar-card.js
  type: module

Configuration

The YAML configuration happens at the root of your Lovelace config under sidebar: at the same level as resources: and views:. Example:

resources:
  - url: /local/sidebar-card.js?v=0.0.1
    type: module   
sidebar:
  title: "Sidebar title"
views:
...

Main Options

Under sidebar: you can configure the following options:

NameTypeDefaultSupported OptionsDescription
titlestringoptionalTitleTitle to show in the sidebar
clockbooleanoptionaltrueShow analog clock in sidebar
datebooleanoptionalfalseIf date is enabled it will display the current date
dateFormatbooleanstringDD MMMMIf date is enabled you define how it should show the date with dateFormat, to see the options check this url: https://momentjs.com/docs/#/parsing/string-format/
digitalClockbooleanoptionaltrueShow digital clock in sidebar
digitalClockWithSecondsbooleanoptionaltrueIf digitalClock is enabled you can also enable to show seconds
twelveHourVersionbooleanoptionalfalseIf digitalClock is enabled you can also enable this to 12 hour version
periodbooleanoptionalfalseIf twelveHourVersion is enabled you can enable this to show 'AM' or 'PM'
sidebarMenuobjectoptionalsee info belowCreate a menu that can switch to different pages but also call any service you want
updateMenubooleanoptionaltrueWhen false the active state of the sidebar will not change by navigating to a different view
templatetemplateoptionalsee info belowTemplate rules that will show messages to inform you for example with how many lights are on
stylecssoptionalsee info belowOverwrite some color variables or write your own styles
widthobjectoptionalsee info belowThe width of the sidebar in percentages for different screens
breakpointsobjectoptionalsee info belowFor the width we set different sizes for different screens with breakpoints you can overwrite these breakpoints
bottomCardobjectoptionalsee info belowDefine any card that will be rendered at the bottom of the sidebar
showTopMenuOnMobilebooleanoptionaltrueIf you hide the top menu you can set this to true so that it will be shown on mobile
hideHassSidebarbooleanoptionaltrueHide the home assistant sidebar
hideOnPatharrayoptional/lovelace/cameraIf you don't want the sidebar on every path you can add a list of paths where it should hide the sidebar
hideTopMenubooleanoptionaltrueHide the top home assistant menu
debugbooleanoptionalfalseShow debugging messages in the browser's developer console

When using hideTopMenu and/or hideHassSidebar you can disable this by adding ?sidebarOff to the url. For example you get this url: https://myhomeassistant.duckdns.org/lovelace/home?sidebarOff

Width

The width of the sidebar can be manually specified. By default it will be 25% of the width on all screens. With the width option you can set the width for 3 sizes: mobile, tablet and desktop. You can also set the width to 0 to make the sidebar not appear.

Example to set width (This example hides the sidebar on mobile):

sidebar:
  width:
    mobile: 0
    tablet: 25
    desktop: 20

Breakpoints

Above we have set the width for 3 sizes but you can also set the breakpoints for these sizes to change the moment the size of the page changes. The breakpoint is activated when the width is smaller or equal to the value that is set. Default mobile is 768px or smaller, tablet 1024px or smaller and above 1024px is desktop.

Example to set breakpoints:

sidebar:
  breakpoints:
    mobile: 768
    tablet: 1024

sidebarMenu

To add a menu to the sidebar you can use sidebarMenu. Within the sidebarMenu you can add actions which will show as menu items. Below is a table with options for these actions:

NameTypeDefaultSupported OptionsDescription
actionstringtogglemore-info, toggle, call-service, none, navigate, urlAction to perform
entitystringnoneAny entity idOnly valid for action: more-info and action: toggle to call more-info pop-up for this entity or toggle this entity
navigation_pathstringnoneEg: /lovelace/0/Path to navigate to (e.g. /lovelace/0/) when action defined as navigate
url_pathstringnoneEg: https://www.google.frURL to open on click when action is url. The URL will open in a new tab
servicestringnoneAny serviceService to call (e.g. media_player.media_play_pause) when action defined as call-service
service_dataobjectnoneAny service dataService data to include (e.g. entity_id: media_player.bedroom)
iconstringnoneAny icon (Eg: mdi:)Display icon besided the name
statestringnoneAny entity light.demoSet an entity (light, switch etc.) and when this entities state is on the item will display on and when it is off it will be displayed off

When you use the navigation action type (see example below) and set the navigation_path to the lovelace views it will act as a normal menu and display an active state when you are on the url you defined in the sidebarMenu.

sidebar:
  sidebarMenu:
    - action: navigate
      navigation_path: "/lovelace/home"
      name: "Home"
      active: true
    - action: navigate
      navigation_path: "/lovelace/lampen"
      name: "Lampen"
    - action: navigate
      navigation_path: "/lovelace/music"
      name: "Muziek"
    - action: navigate
      navigation_path: "/lovelace/4"
      name: "Test"
    - action: toggle
      entity: light.beganegrond
      name: Lichtstrip
      state: light.beganegrond
      icon: mdi:led-strip-variant

Template

The template option gives you a place to template a list of messages than can be shown. Every message must start with the HTML tag <li> and end with </li>. Within the tags you can template your message.

For example, to say Goedemorgen == Good morning for non dutch people, or display how many lights or media_players are on, etc. Additional examples are below:

sidebar:
  template: |
    <li>
      {% if now().hour  < 5 %} Goede nacht {{'\U0001F634'}}
      {% elif now().hour < 12 %} Goedemorgen {{'\u2615\uFE0F'}}
      {% elif now().hour < 18 %} Goedenmiddag {{'\U0001F44B\U0001F3FB'}}
      {% else %} Goedenavond {{'\U0001F44B\U0001F3FB'}}{% endif %}
    </li>
    {% if "Vandaag" in states('sensor.blink_gft') %} <li>Vandaag groenebak aan de straat</li> {% endif %}
    {% if "Vandaag" in states('sensor.blink_papier') %} <li>Vandaag oudpapier aan de straat</li> {% endif %}
    {% if "Vandaag" in states('sensor.blink_pmd') %} <li>Vandaag plastic aan de straat</li> {% endif %}
    {% if "Vandaag" in states('sensor.blink_restafval') %} <li>Vandaag grijzebak aan de straat</li> {% endif %}
    {% if "Morgen" in states('sensor.blink_gft') %} <li>Morgen groenebak aan de straat</li> {% endif %}
    {% if "Morgen" in states('sensor.blink_papier') %} <li>Morgen oudpapier aan de straat</li> {% endif %}
    {% if "Morgen" in states('sensor.blink_pmd') %} <li>Morgen plastic aan de straat</li> {% endif %}
    {% if "Morgen" in states('sensor.blink_restafval') %} <li>Morgen grijzebak aan de straat</li> {% endif %}
    {% if states('sensor.current_lights_on') | float > 0 %} <li>{{states('sensor.current_lights_on')}} lampen aan</li> {% endif %}
    {% if states('sensor.current_media_players_on') | float > 0 %} <li>{{states('sensor.current_media_players_on')}} speakers aan</li> {% endif %}

Style

By default there are some variables that you can set to change colors. Of course you can also add your own styles to customize it more. In the below example you can find the variables with the default colors.

Example:

sidebar:
  style: |
    :host {
        --sidebar-background: #FFF;
        --sidebar-text-color: #000;
        --face-color: #FFF;
        --face-border-color: #FFF;
        --clock-hands-color: #000;
        --clock-seconds-hand-color: #FF4B3E;
        --clock-middle-background: #FFF;
        --clock-middle-border: #000;
    }

Bottom Custom Card

To start, add bottomCard to your sidebar config. bottomCard has 3 parts.

  1. type - This can be the default home assistant card or any custom card.
  2. cardOptions - Most cards need some configuration (i.e.: an entity). This should be placed under cardOptions.
  3. cardStyle (optional) - To make sure the card fits your sidebar style you can add extra CSS rules for the card to make it fit better.

Example:

sidebar:
  bottomCard:
    type: horizontal-stack
    cardOptions:
      cards:
        - type: "custom:button-card"
          color_type: card
          color: rgb(255, 255, 255)
          icon: mdi:home
        - type: "custom:button-card"
          color_type: card
          color: rgb(255, 255, 255)
          icon: mdi:lightbulb
    cardStyle: |
      :host {
        width: 100%;
        background-color:#FFF;
      }

Screenshots

Screenshot default

Screenshot styled