user-avatar
A person's picture, or their initials when there's no picture or it fails to load. name is the picture's text alternative (and where the initials come from). size is sm, md, lg or xl. status (online, away, busy, offline) adds a dot, and says so in words for screen readers.
This one has no events: it shows what it's given.
Sizes and statuses
Source: user-avatar.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/user-avatar.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/user-avatar.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/user-avatar.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/user-avatar.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/user-avatar.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/user-avatar.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/user-avatar.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/user-avatar.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/user-avatar.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/user-avatar.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/user-avatar.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/user-avatar.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/user-avatar.js"></script>The compiled install writes src/components/zubra/user-avatar.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<user-avatar name="Ada Lovelace" size="lg" status="online"></user-avatar>
<script type="module">
import './components/zubra/user-avatar.js';
</script>import './components/zubra/user-avatar.js';
export function UserAvatarExample() {
return (
<user-avatar name="Ada Lovelace" size="lg" status="online"></user-avatar>
);
}<script setup>
import './components/zubra/user-avatar.js';
</script>
<template>
<user-avatar name="Ada Lovelace" size="lg" status="online"></user-avatar>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/user-avatar.js';
</script>
<user-avatar name="Ada Lovelace" size="lg" status="online"></user-avatar>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/user-avatar.js';
@Component({
selector: 'app-user-avatar-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<user-avatar name="Ada Lovelace" size="lg" status="online"></user-avatar>
`,
})
export class UserAvatarExample {
}API
| Property | Type | Default |
|---|---|---|
src | string | "" |
name | string | "" |
size | "sm" | "md" | "lg" | "xl" | "md" |
status | "" | "online" | "away" | "busy" | "offline" | "" |
Size
1.2 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.8 KB.