Skip to content

MazAvatar

MazAvatar is a standalone component to display images or svgs in a wrapper

INFO

Before you have to import the global css files in your project, follow instructions in Getting Started

TIP

This component uses vLazyImg directive

Basic usage

avatar image
vue
<template>
  <MazAvatar src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80" />
</template>

<script lang="ts" setup>
  import MazAvatar from 'maz-ui/components/MazAvatar'
</script>

Options

TIP

See all the options props here

LM
avatar image
avatar image
avatar image
vue
<template>
  <MazAvatar
    caption="Louis Mazel"
    size="1.5rem"
  />
  <MazAvatar
    src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=maz-ui"
    size="2rem"
    href="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=maz-ui"
    target="_blank"
    rounded-size="none"
    clickable
    no-size
  >
    <template #icon>
      <MazIcon name="eye" />
    </template>
  </MazAvatar>
  <MazAvatar
    src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=200"
    size="2.5rem"
    clickable
    rounded-size="xl"
    @click="clicked"
  />
  <MazAvatar
    src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=600"
    size="3rem"
    bordered
  />
</template>

<script lang="ts" setup>
  import MazAvatar from 'maz-ui/components/MazAvatar'
  const clicked = () => { console.log('clicked') }
</script>

On Error

avatar image
html
<MazAvatar @error="error" />

Fallback image loaded on error

avatar image
html
<MazAvatar fallback-src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=100" />

Props, Event & Slots

Props

Prop nameDescriptionTypeValuesDefault
srcThe source of the imageunion-undefined
captionThe caption of the avatarunion-undefined
hrefThe link of the avatarstring-undefined
toThe link (router-link) of the avatarunion-undefined
altThe alt of the imagestring-'avatar image'
targetThe target of the linkstring-'_self'
sizeThe size of the avatarstring-undefined
borderedAdd a border to the avatarboolean-
clickableMake the avatar clickableboolean-
squareMake the avatar squareboolean-
noElevationRemove the shadowboolean-
showCaptionShow the captionboolean-
imageHeightFullMake the image height fullboolean-
noLoaderRemove the loaderboolean-
buttonColorThe color of the clickable buttonColor-'info'
noClickableIconRemove the icon on hover when component is clickableboolean-
letterCountNumber of letters to display in the round textnumber-undefined
roundedSizeSize of the rounded
@values 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'
union-'full'
fallbackSrcThe fallback src to replace the src on loading errorstring-undefined
noPhotoLoad the fallback image by defaultboolean-

Events

Event namePropertiesDescription
click
errorEmitted when the image is in error
loadedEmitted when the image is loaded
loadingEmitted when the image is loading
intersectingEmitted when the image is intersecting

Slots

NameDescriptionBindings
round-text
icon
caption