Avatar

PRO

You can edit 8 Components for free. Get premium for unlimited access.

An image element with a fallback for representing the user.

Jetpack Compose

The Avatar component is used to display profile pictures or provide easy visual access to account settings.

1. Reference

This component inherits props from the Avatar.

Prop
Type
Default
type
AvatarType.icon
AvatarType.image
AvatarType.initials

-

size
AvatarSize.xs
AvatarSize.sm
AvatarSize.md
AvatarSize.lg
AvatarSize.lg
state
AvatarState.default
AvatarState.offline
AvatarState.online
AvatarState.default

2. Type

You can edit the type with the AvatarType.icon, AvatarType.image or AvatarType.initials parameter.

NB
avatar-img
Avatar(
size = AvatarSize.md,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.default
)

Avatar(
size = AvatarSize.md,
type = AvatarType.initials(text:"Aa"),
state = AvatarState.default
)

Avatar(
size = AvatarSize.md,
type = AvatarType.image(AvatarImage.Drawable(R.drawable.img_person)),
state = AvatarState.default
)

3. Size

You can edit the size with the AvatarSize.xs, AvatarSize.sm, AvatarSize.md or AvatarSize.lg parameter.

Avatar(
size = AvatarSize.lg,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.default
)

Avatar(
size = AvatarSize.md,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.default
)

Avatar(
size = AvatarSize.sm,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.default
)

Avatar(
size = AvatarSize.xs,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.default
)

4. State

You can edit the state with the AvatarState.default, AvatarState.offline or AvatarState.online parameter.

Avatar(
size = AvatarSize.md,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.default
)

Avatar(
size = AvatarSize.md,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.offline
)

Avatar(
size = AvatarSize.md,
type = AvatarType.icon(R.drawable.profile),
state = AvatarState.online
)

Preview

Aa
avatar-img
Wrap(
  spacing: DlSpacingTokens.p_12,
  runSpacing: DlSpacingTokens.p_12,
  children: const [
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.icon
    ),
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.initials,
      initials: 'Aa'
    ),
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.image
    ),
  ],
)
Copy

Usage

Add this code example to your project to see how the component works.

DlAvatar(
    size: DlAvatarSize.lg,
    type: DlAvatarType.initials,
    initials: 'Aa',
    state: DlAvatarState.defaultState
    )
Copy

API Reference

DlAvatar is a rounded token-based avatar component that supports multiple sizes, icon/initials/image types, and optional online/offline status indicators.

Prop
Type
Default
size
lg
md
sm
xs
lg
state
defaultState
online
offline
defaultState
type
icon
initials
image
icon
initials
String
AA

Examples

Size

Wrap(
  spacing: DlSpacingTokens.p_12,
  runSpacing: DlSpacingTokens.p_12,
  children: const [
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.icon
    ),
    DlAvatar(
      size: DlAvatarSize.md,
      type: DlAvatarType.icon
    ),
    DlAvatar(
      size: DlAvatarSize.sm,
      type: DlAvatarType.icon
    ),
    DlAvatar(
      size: DlAvatarSize.xs,
      type: DlAvatarType.icon
    ),
  ],
)
Copy

State

Wrap(
  spacing: DlSpacingTokens.p_12,
  runSpacing: DlSpacingTokens.p_12,
  children: const [
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.icon
    ),
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.icon,
      state: DlAvatarState.offline
    ),
    DlAvatar(
      size: DlAvatarSize.lg,
      type: DlAvatarType.icon,
      state: DlAvatarState.online
    ),
  ],
)
Copy

Discover more content

You have questions or need help?

E-Mail

You want to try?

Test for free

Save time and money?

Get Pro Version