kinghat / tabbed-card

a custom card for home assistant that utilizes tabs to segregate individual cards.
MIT License
87 stars 10 forks source link

minWidth: true doesn't not minimize width to icon size #91

Open Mariusthvdb opened 1 year ago

Mariusthvdb commented 1 year ago

not sure if (where) we've discussed this before, so please allow me a dedicated issue on the matter.

using a main

type: custom:tabbed-card
attributes:
  minWidth: true
  isMinWidthIndicator: true

config one a set of tabbed cards only using an icon in the tab, still makes the card tabs go beyond the width of a single card, and added to that, we can not swipe it really. the overflow icon somewhat comes in sight when the one next to it is activated, but there's no real swiping the tabs

Maybe I am misconfiguring, if so please correct, but I would have hoped that 4 or 5 icons only should be able to be seen directly and not have it look like:

Scherm­afbeelding 2023-02-21 om 13 28 47 Scherm­afbeelding 2023-02-21 om 13 29 17

seems the minWidth indicator is working correctly, because this is without. As you can see, the tabs are just as wide in both configurations.

Scherm­afbeelding 2023-02-21 om 13 28 23

of course, I have also tried to set that option on the card itself:

    attributes:
      icon: mdi:home-roof
      minWidth: true

to no avail though, no difference at all Please have a look why those tabs are not tighter, just as tight as the indicator

gryzli133 commented 1 year ago

Same issue here, I would like to have 6-7 tabs with just an icon. Normally they could be all visible without scrolling, when they have no margins on both sides of the icon. Setting "minWidth: true" also did not changed that:

image

Mariusthvdb commented 1 year ago

you can do that using this:

type: custom:mod-card
card_mod:
  style:
    tabbed-card $:
      mwc-tab:
        $:
          mwc-tab-indicator $: |
           .mdc-tab-indicator__content--underline {
              border-color: var(--text-color-off) !important;
            }

          .: |
            .mdc-tab {
              min-width: 40px !important;;
              background: var(--primary-color) !important;
            }
            .material-icons {
              display: contents !important;
            }
            .mdc-tab--active {
              --mdc-icon-size: {{states('input_number.active_icon_size')}}px;
              /*background: var(--text-color-off) !important;*/
            }

#     .: |
#       tabbed-card {
#         --mdc-tab-horizontal-padding: 0px;
#       }

card:
  type: custom:tabbed-card
#   attributes:
  #   isFadingIndicator: true
  styles:
    --mdc-tab-horizontal-padding: 0px;
    --mdc-theme-primary: gold
    --mdc-tab-color-default: var(--text-primary-color)
  tabs:

note the horizontal-padding is a card config option, and you need to adjust your own preference for the min-width. Ive set the to 40, but you can play with that

gryzli133 commented 1 year ago

thank you, in case there will be no update soon (solving that issue) then I will use your workaround ;-)

image

crafty35a commented 10 months ago

Maybe it's obvious, but this issue also applies to tabs using short text strings, not just icons:

image

There are 24h and 36h tabs hidden here that could easily fit without scrolling. It would be great for this to be fixed without needing card-mod!

mogim0gi commented 6 months ago

can you please PLEASE implement this, the card-mod cannot be solution to every enhancement suggestion.