Avatar
Overview
Avatar is a pretty useful component showing generally an image. In most case, dimensions are not too high, around 300px max. With AstroPine, you can use Avatar with a fallback text in case you only want to display text (initial name for instance).
Below are differents examples of this component.
Avatar with Image
Just pass an ImageType object to image props and you good to go. Just simply as that.
Copied !
---
import Avatar from "$components/avatar/Avatar.astro";
const image: ImageType = {
src: "https://github.com/shadcn.png",
alt: "@shadcn",
};
---
<div class="flex justify-center align-center p-6 rounded border bg-white">
<Avatar {image} fallbackText="CN" />
</div>
Avatar with Text
The fallbackText props is here in case image don’t show nothing. It’s also useful to just showing text.
Be aware that your text length can break the main purpose display, i.e a full-rounded component.
Copied !
---
import Avatar from "$components/avatar/Avatar.astro";
---
<div
class="flex justify-center align-center flex-wrap gap-3 p-6 rounded border bg-white"
>
<Avatar fallbackText="CN" />
<Avatar fallbackText="CN" color="primary" />
<Avatar fallbackText="CN" color="secondary" />
<Avatar fallbackText="CN" color="success" />
<Avatar fallbackText="CN" color="danger" />
<Avatar fallbackText="CN" color="info" />
<Avatar fallbackText="CN" color="warning" />
<Avatar
fallbackText="CN"
color={{ background: "bg-red-200", text: "text-indigo-500" }}
/>
</div>