# Avatar

> Atom — orn-ui

> ⚠️ Requiere <UIProvider>: Este componente (como todos los de orn-ui) debe renderizarse dentro de un ancestro <UIProvider>, o lanza un error en runtime. See https://orn-ui-docs.vercel.app/getting-started.md

> Corre en Expo SDK 54, 55, 56 y 57, y en React Native puro >=0.81 con react >=19.1. Sin módulos nativos — funciona en Expo Go, sin prebuild.

## Instalación

Instala solo este componente (copia el código fuente a tu proyecto, sin dependencia npm)
```bash
npx orn-ui add avatar
```

O instala el paquete completo e impórtalo
```tsx
pnpm add orn-ui
import { Avatar } from 'orn-ui/avatar';
```

Depende de: core (theme + icons)

## Variantes

### With icon

```tsx
<Avatar size={44}>
  <Icon name="check" size={20} />
</Avatar>
```

### With initials

```tsx
<Avatar size={44}>
  <Body style={{ fontWeight: '700' }}>JD</Body>
</Avatar>
```

### Sizes

```tsx
<VariantRow>
  <Avatar size={28}>
    <Body style={{ fontWeight: '700', fontSize: 11 }}>SM</Body>
  </Avatar>
  <Avatar size={44}>
    <Body style={{ fontWeight: '700' }}>MD</Body>
  </Avatar>
  <Avatar size={64}>
    <Body style={{ fontWeight: '700', fontSize: 18 }}>LG</Body>
  </Avatar>
</VariantRow>
```

### Custom color

```tsx
<Avatar size={44} backgroundColor="#00cae130">
  <Icon name="info" size={22} color="#00cae1" />
</Avatar>
```

## Código completo del demo

```tsx
const variants: VariantDef[] = [
  {
    label: 'With icon',
    content: (
      <Avatar size={44}>
        <Icon name="check" size={20} />
      </Avatar>
    ),
  },
  {
    label: 'With initials',
    content: (
      <Avatar size={44}>
        <Body style={{ fontWeight: '700' }}>JD</Body>
      </Avatar>
    ),
  },
  {
    label: 'Sizes',
    content: (
      <VariantRow>
        <Avatar size={28}>
          <Body style={{ fontWeight: '700', fontSize: 11 }}>SM</Body>
        </Avatar>
        <Avatar size={44}>
          <Body style={{ fontWeight: '700' }}>MD</Body>
        </Avatar>
        <Avatar size={64}>
          <Body style={{ fontWeight: '700', fontSize: 18 }}>LG</Body>
        </Avatar>
      </VariantRow>
    ),
  },
  {
    label: 'Custom color',
    content: (
      <Avatar size={44} backgroundColor="#00cae130">
        <Icon name="info" size={22} color="#00cae1" />
      </Avatar>
    ),
  },
];
return <VariantList variants={variants} />;
```

## Props

| Nombre | Tipo | Por defecto | Descripción |
|---|---|---|---|
| `size?` | `number` | 44 | — |
| `backgroundColor?` | `string` | — | — |
| `style?` | `StyleProp<ViewStyle>` | — | — |
