Skip to content

Accordion: animate content height on open/close #1225

Closed Answered by bogdan0083
bogdan0083 asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to figure out how to animate accordion item content height by myself.

  1. Wrap your item content element inside Transition component. Please note that I also added v-if to make sure transition enter/leave functions will be triggered:
      <Transition @enter="onEnter" @leave="onLeave">
        <div
          v-bind="api.getItemContentProps({ value: item.title })"
          class="text-xs overflow-hidden"
          ref="itemContentRefs"
          v-if="api.value.includes(item.title)"
        >
          <div class="py-3 px-4">
            {{ item.content }}
          </div>
        </div>
      </Transition>
  1. Add functions onEnter and onLeave:
const onTransitionEnd = (node, done) => 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bogdan0083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant