Skip to content

Avatar

An avatar shows a person or an organization as a small round or rounded image. Without an image, it shows the initials of the given text. Use it in lists, headers and profile views.

Avatar

func view(wnd core.Window) core.View {
    return HStack(
        avatar.Text("Ada Lovelace"),
        avatar.Text("Grace Hopper").Size(L64),
        avatar.Text("Alan Turing").Size(L80).Style(avatar.Rounded),
        avatar.Text("Linus").Size(L96).Action(func() {
            // open the profile
        }),
    ).Gap(L24)
}

Constructors

func Embed(data []byte) TAvatar

Embed creates an avatar directly from raw image data.

func Text(paraphe string) TAvatar

Text creates a text-based avatar using initials derived from the given string.

func TextOrImage(text string, img image.ID) TAvatar

TextOrImage creates an avatar from either an image (if provided) or falls back to a text-based avatar.

func URI(uri core.URI) TAvatar

URI creates an avatar from a given image URL.

Methods

MethodDescription
Action(fn func()) TAvatarAction sets an optional click action for the avatar.
Border(border ui.Border) TAvatarBorder sets the border style of the avatar.
Size(widthAndHeight ui.Length) TAvatarSize sets the avatar’s size and adjusts text size and image resolution accordingly.
Style(style Style) TAvatarStyle sets the avatar’s border style (circle by default, rounded when specified).

Related