Search documentation v0.9.0

Morphing Text

Smoothly transition between words

Source ↗️ Report Issue ↗️

Use the MorphingText component to smoothly transition between words. The component creates captivating visuals that grab users attention and makes a memorable impression.

Preview
Svelte
Unlock code
How to use the MorphingText component in Astro
<MorphingText texts={['Astro', 'Svelte', 'React']} />

The component only expects an array of strings for the texts prop to make it work. You can define as many words as you need.

If you’re looking for a different type of text animation, check out the documentation of our RotatingText component.

Colors

The words are created using native HTML elements, meaning you can use CSS to style the text in any way you like. For example, to change the color of the text, you can use the className prop to attach a class name to the element that you can target with CSS:

Svelte
Unlock code
How to change the style of the component
<MorphingText
texts={['Astro', 'Svelte', 'React']}
className="morphing-text"
/>
<style is:global>
.morphing-text {
color: var(--w-color-info);
}
</style>

Animation Timing

By default, the animation plays over 1000ms. This, along with the delay between words can be configured with the animationTime and wordDelay props. Both props expect the time in seconds:

Default
Svelte
Animation set to 2sec
Svelte
Unlock code
How to change animation timing
<MorphingText
texts={['Astro', 'Svelte', 'React']}
animationTime={2}
wordDelay={2}
/>

Sizes

Although font-size can be changed through CSS, the component has a size prop you can use to make size adjustments quicker. Changing the size will affect the effect of the animation.

Svelte
Unlock code
How to change font size
<MorphingText
texts={['Astro', 'Svelte', 'React']}
size="42pt"
/>

API

Unlock code
Component API reference
type MorphingTextProps = {
texts: string[]
size?: string
animationTime?: number
wordDelay?: number
className?: string
}
PropDefaultPurpose
texts [] Sets the list of texts.
size 72pt Sets the font size of the texts.
animationTime 1 Sets the animation time in seconds.
wordDelay 1 Sets the delay between words in seconds.
className - Pass additional CSS classes for the component.