Avatar
A user image with a fallback.
Anatomy
<script>
import { Avatar } from '@shardsui/svelte/avatar'
</script>
<Avatar.Root>
<Avatar.Image />
<Avatar.Fallback />
</Avatar.Root>API reference
Root
Groups the image and its fallback. Renders a <span> element.
Image
Renders an <img> element.
The component preloads the image — applying the same src, srcset, sizes, crossorigin and referrerpolicy — so the loading status is known from the first render. The <img> mounts only once the image has loaded, which is why it can be animated in with data-starting-style; see Animation.
Fallback
Rendered while the image is missing, still loading, or failed. Renders a <span> element.
Additional types
ImageLoadingStatus
The status passed to onLoadingStatusChange, and to the children snippet of Root and Fallback as imageLoadingStatus.
type ImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error'