Customizing expansion-panel__header height

Viewed 3726

Working in Vuetify 1.3.0, trying to make thinner expansion panels than the default.

By default it seems to render pretty big ime, but I can't find the right rules to adjust the element height.

I tried tweaking the header style padding (which by default is 12px 24px), but that just changed where my header was in the overall panel content, so clearly something else is setting the parent element height, I just can't seem to track it down.

My component right now is (simplified) like this:

<template>
  <section>
    <v-expansion-panel>
      <v-expansion-panel-content>
        <header class='layout row justify-spaces ma-0' slot='header'>
          <span class='caption flex' v-text='title'/>
        </header>
      </v-expansion-panel-content>
    </v-expansion-panel>
  </section>
</template>
<style>
  .v-expansion-panel__header: {
      padding: 6px 12px;
  }
</style>

Somehow the actual height of the element is being set to 48px, but it's greyed out meaning that it's computed at runtime and I can't find what factors are causing that. Walking up the DOM tree, I set line-heights to much smaller, cleared all margins and padding, etc. No luck.

2 Answers

You can modify the style in the lifecyle

    mounted() {
        // Reformat vuetify Headers
        $('.v-expansion-panel__header').toggleClass('pl-2 pa-0 ma-0', true);
        $('.v-expansion-panel__header').css('min-height' ,'30px');
    }

I created a condensed CSS class for v-expansion-panels:

<template>
  ...
  <v-expansion-panels class="condensed" ...>
    ...
  </v-expansion-panels>
  ...
</template>
<style scoped>
.v-expansion-panels.condensed .v-expansion-panel-header {
  padding-top: 2px;
  padding-bottom: 2px;
  min-height: auto;
}
.v-expansion-panels.condensed
  .v-expansion-panel--active
  .v-expansion-panel-header {
  padding-top: 8px;
  padding-bottom: 8px;
}
.v-expansion-panels.condensed .v-expansion-panel--active:not(:first-child),
.v-expansion-panels.condensed .v-expansion-panel--active + .v-expansion-panel {
  margin-top: 4px;
}
</style>
Related