Skip to content

Import#

import { Avatar } from '@dnb/eufemia'

Description#

Avatars are identifiers that make people and companies more scannable for payments, spending overviews, and social functionality. The fallback for a person is the letter version that uses the first letter of a person's name. A company has the icon version as its default/fallback. The badge is used to mark country/currency if needed.

Relevant links#

Related components#

Avatar is part of the Content category. Other components for similar needs:

  • Accordion — to let people open and close sections of related content.
  • Card — to group related content in a clear, separated area.
  • CountryFlag — to show a country by its flag from an ISO country code.
  • DateFormat — to show dates in the correct DNB format.
  • Heading — to create accessible page headings with the correct level.
  • Icon — to render and size an icon in line with Eufemia styling.

See all in Content

Demos#

Avatar#

To ensure the correct use of Avatars, we require using a Avatar.Group with Avatar-components as children.
The required label-property in Avatar.Group will ensure the correct use of accessibility for screen readers.
See more examples below.

Setting property size#

default size is 'medium'#

PersonsOla Nordmann

size 'small'#

Text AnimalsDuck Text

size 'medium'#

StocksNFLX

size 'large'#

CompaniesAmazon

size 'x-large'#

TV ShowsFriends

Setting property variant#

default variant is 'primary'#

DogsKleiner münsterländer

variant 'primary'#

CitiesOslo

variant 'secondary'#

CountriesSpain

variant 'tertiary'#

CarsTesla

Passing icon#

Auto-size#

An icon will automatically be given the correct size (size="auto") unless the icon's size property is set.

Bank icons

Accepted values#

The icon property can accept either an imported icon, a primary icon string, or an <Icon> or <IconPrimary> component.

import {
calendar_medium as CalendarMedium,
} from '@dnb/eufemia/icons'
Icons

Passing children#

Icon as child#

A single <Icon> or <IconPrimary> component sent as a child will also follow the same auto sizing rules as the icon property.

Icons

Passing image as src#

Icons
DNB Logo
Banks
DNB Logo
Profiles
Profile picture
Images of banks
DNB Logo

Grouping Avatars#

Text FriendsAndersBjørnarCathrineDidrikErlend+2 Text
EmployeesAndersBjørnarCathrineDidrik+3
BorrowersAndersBjørnarCathrine+4
EnemiesAndersBjørnar+5
Eufemia contributors
Profile picture
Profile picture
Profile picture
Profile picture
+3

Customizing colors#

PersonsOla Nordmann

Avatar with a CountryFlag as a Badge#

PersonsANorgePersonsANorgePersonsANorgePersonsANorge

Avatar with CountryFlag children#

MarketsNorgeFinlandSverigeMarketsNorgeFinlandSverige
Suggest an edit