Components
Avatar New · experimental
shadcn's Avatar. When the image loads, or the fallback appears, it plops in with a small gooey settle.
Customize
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
| Prop | Type | Default | Notes |
|---|---|---|---|
class | string | array | object | Merged onto the root. | |
asChild, as | The element to render, via reka-ui. | ||
settle | boolean | number | true | The image or fallback plops in with a soft overshoot when it appears. A number scales it. false: shadcn's Avatar. |
speed | number | 1 | Animation speed multiplier. |
preset | 'subtle' | 'playful' | 'wild' | app config, then playful | The 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.