question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add show/hide button card (and make that templatable too..)

See original GitHub issue

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I’m always frustrated when […]

I need some of my buttons to show/hide depending on a templated value, in this case view:

      [[[ return window.location.pathname.split('lovelace/')[1]; ]]]

The above is used in various config templates, but I couldn’t find a way to show/hide a full button based in this. Not can I use state-switch, or conditional core card for that matter.

Describe the solution you’d like A clear and concise description of what you want to happen.

Id wager a new config variable show: could be added, either being boolean hard coded, or using a template like the above

Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.

conditional core card state-switch custom card Additional context Add any other context or screenshots about the feature request here.

Schermafbeelding 2020-07-10 om 14 15 31

is an experimental short cut menu bar. I which I would like to have the current view button be hidden (now highlighted)

if at ll possible, it would also need to auto slide in, and not leave a gap in de middle of the button-bar… This is where my hopes are set on stack-in-card 😉

first couple of menu buttons of the above:

type: vertical-stack
cards:

  - type: custom:stack-in-card
    mode: horizontal
    keep:
      background: true
    cards:

      - type: custom:button-card
        template: button_shortcut_menu
        icon: mdi:home
        tap_action:
          action: navigate
          navigation_path: home
        variables:
           path: home
        styles:
          icon:
            - color: >
                [[[
                  return (states['sensor.count_alerts_notifying'].state > 0)
                  ? 'red': 'green';
                ]]]
        state:
          - operator: template
            value: >
              [[[ return (states['sensor.count_alerts_notifying'].state > 0) ]]]
            spin: true
#        spin: >
#            [[[ return (states['sensor.count_alerts_notifying'].state > 0)
#                ? true : false; ]]]

      - type: custom:button-card
        template: button_shortcut_menu
        icon: mdi:light-switch
        tap_action:
          action: navigate
          navigation_path: lights
        variables:
          path: lights
        styles:
          icon:
            - color: >
                [[[
                  return (states['group.all_inside_lights'].state == 'on')
                  ? 'gold': 'grey';
                ]]]

      - type: custom:button-card
        template: button_shortcut_menu
        icon: mdi:home-outline
        tap_action:
          action: navigate
          navigation_path: home_summary
        variables:
          path: home_summary
        styles:
          icon:
            - color: >
                [[[
                  if (states['sensor.hubs_badge'].state > 0 ||
                          states['sensor.status_badge'].state > 0)
                  return 'red'; return 'var(--text-primary-color)';
                ]]]
          card:
            - animation: >
                [[[ return (states['sensor.hubs_badge'].state > 0 ||
                          states['sensor.status_badge'].state > 0)
                    ? 'blink 2s ease infinite' :'none';
                ]]]

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
emufancommented, May 3, 2022

I came here, because I searched for a display/hide filter as well. Would be great to have it out of the box.

Until then, I will stay with this apporach

        styles:
          card:
            - display: |
                [[[
                  return `none`
                ]]]
            - width: |
                [[[
                  return `0`
                ]]]

With some JS if around of course.

0reactions
michalk-kcommented, May 15, 2022

Incidentally, recently I’m trying to resolve the same issue as Marius. I found that styles: card: affects the card’s ha-card element. But it’s wrapped by `button-card which still allocates the space in a layout.

Thank you for @emufan for the workaround!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fun with custom:button-card - Dashboards & Frontend
I've recently discovered the power of custom:button-card (GitHub ... add show/hide button card (and make that templatable too..).
Read more >
Custom Button Card - Has anyone had success getting a ...
I'm just trying to get the temperature to display next to the name of the room. Each room is basically made of of...
Read more >
show hidden part of the dynamic card on button click in meteor
I have created a card dynamically and hide some part of the content by taking it in another template and called on each...
Read more >
Board view – Notion Help Center
Create a board; Full-page board; Inline board; Add board view to a database; Cards: pages in board view; Open a card as a...
Read more >
Replace “Add to cart” with a contact link - Shopify Help Center
To replace the Add to cart button for a product, you will need to create a ... have hidden the Add to cart...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found