Vue Boring Avatars

1.4.0 · active · verified Sun Apr 19

vue-boring-avatars is a dedicated Vue 3 library that generates customizable, SVG-based user avatars. It is a direct port of the popular `Boring Avatars` JavaScript library, ensuring API parity with its React counterpart. Currently at stable version `1.4.0`, the library demonstrates an active release cadence, frequently updating to match new features and improvements introduced in the upstream `Boring Avatars` project. Key differentiators include its full support for Vue 3 and TypeScript, the provision of type definitions out-of-the-box, and robust accessibility features, such as `role` and `title` attributes for generated SVGs. It offers various avatar patterns (bauhaus, beam, marble, pixel, ring, sunset) and allows extensive customization through name, size, square shape, and color palettes, making it a flexible choice for profile picture generation.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to integrate and use the `Avatar` component with various props in a Vue 3 Composition API setup, including dynamic name and size, different variants, and accessibility features.

<template>
  <input type="text" v-model="name" placeholder="Enter name" />
  <input type="number" v-model.number="size" min="20" max="200" placeholder="Enter size" />

  <h3>Bauhaus Variant</h3>
  <Avatar :size="size" variant="bauhaus" :name="name" :colors="['#92A1C6', '#146A7C', '#F0AB3D', '#C271B4', '#C20D90']" />

  <h3>Beam Variant (Square, with title)</h3>
  <Avatar :size="size" variant="beam" :name="name" :square="true" :title="true" :id="'beam-avatar'" />

  <h3>Marble Variant (Default)</h3>
  <Avatar :size="size" variant="marble" :name="name" />

  <h3>Pixel Variant</h3>
  <Avatar :size="size" variant="pixel" :name="name" :square="true" :title="true" />
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import Avatar from 'vue-boring-avatars';

export default defineComponent({
  name: 'AvatarDemo',
  setup() {
    const name = ref('Clara Barton');
    const size = ref(80);

    return {
      name,
      size
    };
  },
  components: {
    Avatar
  }
});
</script>

view raw JSON →