Avatar

Components

Avatar New · experimental

shadcn's Avatar. When the image loads, or the fallback appears, it plops in with a small gooey settle.

TMALGH
Press replay to watch them settle again.

Customize

Preset
Speed 1.00×
Settle 1.00×

GoopAvatar, GoopAvatarImage, and GoopAvatarFallback wrap reka-ui's AvatarRoot, AvatarImage, and AvatarFallback, like shadcn-vue's Avatar. Image loading, delayMs, and the fallback swap all come from reka-ui.

Installation

Install @goopui/nuxt or @goopui/vue as shown on the Button page. The Nuxt module auto-imports all three.

Usage

<script setup lang="ts">
// Nuxt auto-imports these. In plain Vue, import them:
import { GoopAvatar, GoopAvatarFallback, GoopAvatarImage } from '@goopui/vue'
</script>

<template>
  <GoopAvatar>
    <GoopAvatarImage src="/me.png" alt="Tim McMasters" />
    <GoopAvatarFallback>TM</GoopAvatarFallback>
  </GoopAvatar>
</template>

What it does

  • settle. reka-ui renders the image only once it has loaded. When it appears (and when the fallback appears), it scales in from about 80%, overshoots by a few percent with a slight squash, rebounds, and settles. It plays once per appearance.

It's a single CSS animation on a transform, with no script. While the settle is on, the avatar lets the overshoot show past its circle, and the image rounds its own corners.

Turn it off with :settle="false", or scale the overshoot with a number.

Props

GoopAvatar props
PropTypeDefaultNotes
classstring | array | objectMerged onto the root.
asChild, asThe element to render, via reka-ui.
settleboolean | numbertrueThe image or fallback plops in with a soft overshoot when it appears. A number scales it. false: shadcn's Avatar.
speednumber1Animation speed multiplier.
preset'subtle' | 'playful' | 'wild'app config, then playfulThe feel.

GoopAvatarImage takes reka-ui's src, referrerPolicy, and crossOrigin, and emits loadingStatusChange. GoopAvatarFallback takes delayMs, as, and asChild. Both take class.

Accessibility

Give the image an alt. Under reduced motion the avatar appears at once, without the settle. See Accessibility & reduced motion.