Edit Profile

Dark Mode

Copy config

Copy and paste the following code into your global.css file to apply the styles.

WARNING: This component is in
Draft
status. This means that it is still in development and may have bugs or missing features. It is not intended to be used in production. You may use it for testing purposes.

Avatar

An image element with a fallback for representing the user.

@mhevery
MA

Installation

Run the following cli command or copy/paste the component code into your project

qwik-ui add avatar
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
import { cn } from '@qwik-ui/utils';
 
export const Avatar = component$<PropsOf<'div'>>(({ ...props }) => {
  return (
    <div
      {...props}
      class={cn(
        'relative flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full',
        props.class,
      )}
    >
      <Slot />
    </div>
  );
});
 
export const AvatarImage = component$<PropsOf<'img'>>(({ ...props }) => (
  <img {...props} class={cn('aspect-square h-full w-full', props.class)} />
));
 
export const AvatarFallback = component$<PropsOf<'div'>>(({ ...props }) => {
  return (
    <div
      {...props}
      class={cn(
        'bg-muted absolute -z-10 flex h-full w-full items-center justify-center rounded-full',
        props.class,
      )}
    >
      <Slot />
    </div>
  );
});

Usage

import { Avatar } from '@qwik-ui/styled';
<Avatar />