Implementing the Fancy-Components Wave Filter Web Component Across Frontend Frameworks

This article explains how to replace a heavy 78 KB GIF loading animation with the lightweight Fancy-Components wave‑filter web component, covering its installation, configuration, and usage in plain HTML, React, Vue 2, Vue 3, Vue‑CLI, Vite, and custom attribute options such as color, duration, amplitude, delay, mode, and interval.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Implementing the Fancy-Components Wave Filter Web Component Across Frontend Frameworks

The author discovered that a 78 KB GIF used as a loading placeholder could be replaced by a CSS‑based wave animation using the fancy-components library, which provides a <fc-wave-filter> web component.

After installing the library ( npm i fancy-components), the component can be used in a plain HTML file by adding a <script type="module"> tag that imports FcWaveFilter and creates a new instance.

In React projects, the component is imported and rendered as

<fc-wave-filter color="#047"><img src="..."/></fc-wave-filter>

, noting that the tag must be lowercase.

For Vue 2, the component is imported, registered, and used with Vue.config.ignoredElements = [/^fc-/] to prevent Vue warnings about unknown elements.

Vue 3 projects using the Vue‑CLI require a vue.config.js modification to treat tags starting with fc- as custom elements, while Vite projects configure the same behavior in vite.config.js using the isCustomElement compiler option.

The wave filter supports several attributes: color (or CSS variable --color) to set fill color, dur for animation duration, amplitude to adjust wave height, delay to keep the filled state, mode ("alpha", "luminance", "img", "slideshow") to choose the fill strategy, and interval for slideshow timing. These can be set directly on the element or via CSS variables.

Advanced usage includes combining two images for the "img" mode, using masks or clip-path to shape the wave, and dynamically switching modes with Vue's v-if or DOM property assignment. Browser quirks, especially in Chrome, are noted for dynamic attribute changes.

npm i fancy-components
import { FcWaveFilter } from 'fancy-components'
new FcWaveFilter()

Overall, the guide provides a comprehensive, framework‑agnostic method to create lightweight, customizable loading animations without large GIF assets.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

frontendJavaScriptReactCSSweb components
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.