Headless Avatar overview
tngAvatar, tngAvatarImage, and tngAvatarFallback are structural slot directives only. You own sizing, shape, fallback visibility, and load-error behavior.
Imports
Use the three directives together when you want full control over the avatar markup.
Headless imports
ts
import { TngAvatar, TngAvatarImage, TngAvatarFallback } from '@tailng-ui/primitives';
Basic usage
The primitive does not toggle fallback for you. In headless mode, your template decides when the image or fallback should be hidden.
Minimal headless avatar
html
<span tngAvatar class="profile-avatar">
<img
tngAvatarImage
[attr.src]="src()"
[attr.hidden]="showFallback() ? '' : null"
[attr.alt]="showDecorative() ? '' : 'Taylor Nguyen'"
(error)="imageLoadFailed.set(true)"
(load)="imageLoadFailed.set(false)"
/>
<span
tngAvatarFallback
[attr.hidden]="showFallback() ? null : ''"
aria-hidden="true"
>
TN
</span>
</span>
Style variants
The same primitive markup rendered with owner-authored Plain CSS and Tailwind shells.
Headless avatar (Plain CSS)
source mode: valid
Headless avatar (Tailwind CSS)
source mode: valid
Accessibility baseline
- Use meaningful
alttext when the avatar identifies a person. - Use
alt=""andaria-hidden="true"fallback content for decorative avatars. - Keep fallback text short and readable because the primitive does not abbreviate it for you.