diff --git a/docs/content/3.components/avatar.md b/docs/content/3.components/avatar.md
index a856223e..bf52e130 100644
--- a/docs/content/3.components/avatar.md
+++ b/docs/content/3.components/avatar.md
@@ -11,6 +11,10 @@ links:
## Usage
+::tip
+The Avatar uses the `NuxtImg` component when `@nuxt/image` is installed, falling back to `img` otherwise.
+::
+
### Src
Use the `src` prop to set the image URL. You can pass any property from HTML `
` element such as `alt`, `loading`, etc.
diff --git a/src/runtime/components/Avatar.vue b/src/runtime/components/Avatar.vue
index de514b27..726c7e41 100644
--- a/src/runtime/components/Avatar.vue
+++ b/src/runtime/components/Avatar.vue
@@ -15,9 +15,9 @@ type AvatarVariants = VariantProps
export interface AvatarProps extends Pick {
/**
* The element or component this component should render as.
- * @defaultValue 'img'
+ * @defaultValue 'span'
*/
- as?: string | object
+ as?: any
src?: string
alt?: string
icon?: string
@@ -36,10 +36,11 @@ import { AvatarRoot, AvatarImage, AvatarFallback, useForwardProps } from 'radix-
import { reactivePick } from '@vueuse/core'
import { useAvatarGroup } from '../composables/useAvatarGroup'
import UIcon from './Icon.vue'
+import ImageComponent from '#build/ui-image-component'
defineOptions({ inheritAttrs: false })
-const props = defineProps()
+const props = withDefaults(defineProps(), { as: 'span' })
const fallbackProps = useForwardProps(reactivePick(props, 'delayMs'))
@@ -54,10 +55,10 @@ const ui = computed(() => avatar({
-
+
{
+ const image = app?.components?.find(c => c.pascalName === 'NuxtImg' && !c.filePath.includes('nuxt/dist/app'))
+
+ return image ? `export { default } from "${image.filePath}"` : 'export default "img"'
+ }
+ })
+
return templates
}