Skip to content

Instantly share code, notes, and snippets.

@benbartling
Created February 11, 2022 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbartling/796e3527f1b3609702099a9b600ff97c to your computer and use it in GitHub Desktop.
Save benbartling/796e3527f1b3609702099a9b600ff97c to your computer and use it in GitHub Desktop.
Vue Word Rotation Component w/ TailwindCSS
<template>
<span class="word-wrapper">
<span class="filler">---</span>
<span class="word" v-for="(word, index) in words" :key="index">
{{ word }}
</span>
</span>
</template>
<script>
export default {
props: ["words"]
};
</script>
<style lang="sass">
.word-wrapper
@apply inline-block text-left relative text-red-600
.filler
@apply opacity-0
.word
@apply opacity-0 absolute inset-0
animation: topToBottom 10s linear infinite 0s
&:nth-child(2)
animation-delay: 2.5s
&:nth-child(3)
animation-delay: 5s
&:nth-child(4)
animation-delay: 7.5s
@keyframes topToBottom
0%
opacity: 0
5%
opacity: 0
transform: translateY(-100%)
10%
opacity: 1
transform: translateY(0px)
25%
opacity: 1
transform: translateY(0px)
30%
opacity: 0
transform: translateY(100%)
80%
opacity: 0
100%
opacity: 0
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment