Text with a background that sweeps in from the left, like a highlighter.
Installation
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
| Prop | Type | Default |
|---|---|---|
text | string | - |
delay? | number | 0 |
transition? | Transition | { duration: 2, ease: 'easeInOut' } |
in-view? | boolean | false |
in-view-margin? | string | '0px' |
in-view-once? | boolean | true |
...props? | Omit<HTMLMotionProps<'span'>, 'children'> | - |