iced-cube

Feedback

Avatar

A small picture of a person or team, with initials when there is no image.

use iced_cube::{avatar, avatar_group};
use iced_cube::feedback::avatar::{Presence, Shape, Size};
API reference
Presence: A dot on the corner for online, away, busy and offline.Presence: A dot on the corner for online, away, busy and offline.
Static preview
Presence. A dot on the corner for online, away, busy and offline.

Usage

An avatar shows the first thing it has of an image, an icon and the name’s initials, so the same code covers people who have uploaded a picture and those who have not. Initials and icons sit on the muted surface.

Images come from an iced image::Handle. The avatar feature turns on iced’s image widget without any decoders, which is enough for pixels you already have, such as a picture fetched and decoded elsewhere. To load PNG or JPEG files directly, enable iced’s image feature in your app. The GPU renderer crops images to the avatar’s shape; iced’s software fallback draws them with square corners.

The rings around grouped avatars and presence dots are drawn in the page background colour, so they read best on the page itself rather than on a raised card.

Presence colours come from the theme’s status tokens: success for online, warning for away, destructive for busy and the muted foreground for offline. Pair the dot with text, as the presence example does, since colour alone does not say which state it is.

Examples

Image, initials and icon

An image when there is one, otherwise the name's initials, an icon, or a person icon when there is no name.

Image, initials and icon: An image when there is one, otherwise the name's initials, an icon, or a person icon when there is no name.Image, initials and icon: An image when there is one, otherwise the name's initials, an icon, or a person icon when there is no name.
Static preview

Sizes and shapes

Small to extra large, as circles for people and rounded squares for teams.

Sizes and shapes: Small to extra large, as circles for people and rounded squares for teams.Sizes and shapes: Small to extra large, as circles for people and rounded squares for teams.
Static preview

Group

Overlapping avatars, with a count for the ones that do not fit.

Group: Overlapping avatars, with a count for the ones that do not fit.Group: Overlapping avatars, with a count for the ones that do not fit.
Static preview

API

ItemDescription
avatar(name)Creates an avatar showing the name's initials. A name with no letters shows a person icon.
.image(handle)Shows a picture instead of the initials, cropped to fill the shape.
.icon(glyph)Shows a Lucide icon instead of the initials, such as a bot for an automated account.
.size(Size)Sm, Md, Lg or Xl: 24, 32, 40 or 56 pixels across. Defaults to Md.
.shape(Shape)Circle for people or Square, with rounded corners, for teams and organisations. Defaults to Circle.
.presence(Presence)Adds a dot for Online, Away, Busy or Offline on the bottom right corner.
avatar_group(avatars)Overlaps avatars from left to right, each ringed in the background colour.
.size(Size) / .max_items(n)Sets the size of every avatar in a group, and shows at most n places, the last one counting the rest.
avatar::initials(name)The initials an avatar shows: the first letters of the first and last words.
Esc