Skip to content
On this page

Avatar

An Avatar component useful for User Profile Pictures, support uploading new pictures, or display an existing one.

Preview & Playground 🖼️

Here you may find a preview of the component, with error & possible variants.

🏄 Click to expand the code
vue
<script setup lang="ts">
import { Avatar } from '@flavorly/vanilla-components'
import { ref } from 'vue'
const value = ref(null)
const value2 = ref(null)
</script>

<template>
  <PreviewWrapper>
    <!-- Regular -->
    <div class="text-center">
      <Avatar
        v-model="value"
        feedback="Im useful helper out here, choose wisely"
        placeholder="Elon Musk"
      />
    </div>

    <div class="text-center">
      <Avatar
        v-model="value2"
        placeholder="Type to clear errors"
        errors="Sorry for this name is already taken"
        feedback="I only show when i dont have errors"
      />
    </div>
  </PreviewWrapper>
</template>

Props 📥

Props available for this component extending the default variant & global props.

PropDescriptionAccepted ValuesDefault
modelValueThe value for the elementAnyundefined
currentPhotoUrlCurrent Photo URL[String,undefined]undefined
currentPhotoAltTagAlternative Text for the photoString'avatar'
avatarInitialsShort Initials for the AvatarString'avatar'
uploadButtonLabelLabel for the default buttonString'avatar'
resetButtonLabelLabel for the reset buttonString'avatar'
uploadButtonVariantVariant for the upload button[String,undefined]undefined
resetButtonVariantVariant for the reset button[String,undefined]'undefined'

Slots 🧬

Current slots available for this component are the following:

Slot photo

Slot dedicated to show the current photo preview, binds all the props passed to the component, plus the following:

AttributeDescriptionType
triggerFileUploadActionFunction to trigger uploadFunction

Slot preview

Slot dedicated to showing the preview of the new uploaded photo, binds all the props passed to the component, plus the following:

AttributeDescriptionType
photoPreviewBase64 enconded blob[Blog, String]

Slot uploadButton

Slot to override the default upload button next to the profile photo

AttributeDescriptionType
triggerFileUploadActionFunction to trigger uploadFunction
photoPreviewBase64 enconded blob[Blog, String]

Slot resetButton

Slot to override the default reset button next to the profile photo and when a preview is in place

AttributeDescriptionType
resetPhotoFunction to reset the uploadFunction
photoPreviewBase64 enconded blob[Blog, String]

Slot errors

Slot that holds the error messages when the component errors prop is defined.

AttributeDescriptionType
errorsThe errors being injected[String, Array, Undefined]
feedbackThe feedback message[String, Undefined]
hasErrorsIf it has errorsBoolean

Slot feedback

Slot that holds the feedback messages when the component feedback prop is defined. When showing errors the feedback will be hidden by default, and vice-versa.

AttributeDescriptionType
errorsThe errors being injected[String, Array, Undefined]
feedbackThe feedback message[String, Undefined]
hasErrorsIf it has errorsBoolean

Events 🚇

Here you may find the events emitted by this component.

EventDescriptionValue
openSlideover was openedBoolean
previewUpdatedPreview was updatedBlob
previewResetPreview was removed/resettrue
uploadTriggeredUpload button pressedtrue

Released under the MIT License.