Vue Blurhash Components

0.1.4 · maintenance · verified Sun Apr 19

The `vue-blurhash` package provides a set of Vue 2 components designed to implement Blurhash image placeholders. It allows developers to display a compact, low-resolution representation of an image while the full-resolution image loads, enhancing the perceived performance and user experience of web applications. The library offers two primary components: `<blur-hash-image>` for a complete image loading solution including an optional fade transition, and `<blur-hash-canvas>` for generating only the Blurhash placeholder on a canvas, enabling custom image loading logic. As of its current stable version 0.1.4, it specifically targets Vue.js 2.0+ environments. Its release cadence appears infrequent, typical for a specialized utility library tied to an older major framework version. A key differentiator is its straightforward integration as a Vue plugin, simplifying the process of adding Blurhash functionality without extensive manual implementation of the `blurhash` algorithm itself.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to register `vue-blurhash` as a Vue 2 plugin, import its necessary CSS, and then utilize both the `<blur-hash-image>` component for a complete image loading experience and the `<blur-hash-canvas>` for just displaying the blurhash placeholder.

import Vue from 'vue';
import VueBlurHash from 'vue-blurhash';
import 'vue-blurhash/dist/vue-blurhash.css'; // For fade transition effect

Vue.use(VueBlurHash);

new Vue({
  el: '#app',
  template: `
    <div id="app">
      <h1>Image with Blurhash Placeholder</h1>
      <blur-hash-image
        width="400"
        height="300"
        hash="LdHfL}oJR$WBKnfi%3ofT0kCM{ay"
        src="https://images.unsplash.com/photo-1545910684-8e7c081be9b0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1867&q=80"
        alt="green lawn grass during daytime"
        transitionDuration="800"
      />
      <h2>Canvas-only Placeholder</h2>
      <blur-hash-canvas
        hash="LdHfL}oJR$WBKnfi%3ofT0kCM{ay"
        width="200"
        height="150"
        punch="1.2"
      />
    </div>
  `,
});

view raw JSON →