Highlight Text

Text with a background that sweeps in from the left, like a highlighter.

<script setup lang="ts">
import { RefreshIcon } from '@hugeicons/core-free-icons'
import { HugeiconsIcon } from '@hugeicons/vue'
import { HighlightText } from '@animate-ui/vue/primitives/texts/highlight'
import { ref } from 'vue'
import { Button } from '@/components/ui/button'

withDefaults(defineProps<{ delay?: number }>(), { delay: 0 })

const run = ref(0)
</script>

<template>
  <div class="flex flex-col items-center gap-6">
    <HighlightText
      :key="`${run}-${delay}`"
      :delay="Number(delay)"
      class="rounded-md bg-linear-to-r from-blue-100 to-purple-100 px-1 text-4xl font-semibold dark:from-blue-500 dark:to-purple-500"
      text="Highlight Text"
    />
    <Button variant="outline" size="sm" @click="run++">
      <HugeiconsIcon :icon="RefreshIcon" :stroke-width="2" data-icon="inline-start" />
      Replay
    </Button>
  </div>
</template>

Installation

npm install @animate-ui/vue motion-v
pnpm add @animate-ui/vue motion-v
yarn add @animate-ui/vue motion-v
bun add @animate-ui/vue motion-v

Usage

<script setup lang="ts">
import { HighlightText } from '@animate-ui/vue/primitives/texts/highlight';
</script>

<template>
  <HighlightText
    text="Highlight Text"
    class="bg-linear-to-r from-blue-100 to-purple-100"
    in-view
  />
</template>

Animation

  • The background grows from the left edge over 2s on an ease-in-out: slow at first, fastest midway, easing into place.
  • With :in-view-once="false", it resets off screen and sweeps again on the next entrance.
  • <AnimateUIProvider :tempo> paces the default duration.
  • Under reduced motion, the text is highlighted at once.

API Reference

HighlightText

PropTypeDefault
text
string-
delay?
number0
transition?
Transition{ duration: 2, ease: 'easeInOut' }
in-view?
booleanfalse
in-view-margin?
string'0px'
in-view-once?
booleantrue
...props?
Omit<HTMLMotionProps<'span'>, 'children'>-

Built by Skyleen. The source code is available on GitHub.

Last updated: 10/23/2026