pub struct Avatar { /* private fields */ }Expand description
A circular, non-interactive identity marker.
Name-derived avatars use at most the first character of each of the first
two whitespace-separated words. Explicit initials accept at most three
non-whitespace characters. Both forms uppercase Unicode and use "?" when
no character remains.
§Examples
use ailloli_ui_widgets::controls::Avatar;
let avatar = Avatar::new("Ada Lovelace");
let _ = avatar;Implementations§
Source§impl Avatar
impl Avatar
Sourcepub fn width(self, value: impl Into<Length>) -> Self
pub fn width(self, value: impl Into<Length>) -> Self
Sets preferred width from a logical-pixel or length value.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).width(24.0);
let _ = widget;Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).height(24.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).min_width(12.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).max_width(32.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).min_height(12.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).max_height(32.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).margin(4.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).padding(4.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_basis(20.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::{style::AlignItems, IconId};
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).align_self(AlignItems::Center);
let _ = widget;Source§impl Avatar
impl Avatar
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates an avatar whose initials are derived from name.
Two or more words yield the first character of the first two words; one
word yields its first two characters. Blank input yields "?".
§Examples
use ailloli_ui_widgets::controls::Avatar;
let avatar = Avatar::new("Grace Hopper");
let _ = avatar;Sourcepub fn initials(initials: impl Into<String>) -> Self
pub fn initials(initials: impl Into<String>) -> Self
Creates an avatar from explicit initials.
Whitespace is removed, at most three input characters are retained, and
Unicode uppercase expansion may produce more than three output code
points. Blank input becomes "?".
§Examples
use ailloli_ui_widgets::controls::Avatar;
let avatar = Avatar::initials("gh");
let _ = avatar;Sourcepub fn icon(icon: IconId) -> Self
pub fn icon(icon: IconId) -> Self
Creates an avatar whose content is icon.
The icon is centered at 48% of the avatar’s shortest side and tinted
with AvatarStyle::icon_tint.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::Avatar;
let avatar = Avatar::icon(IconId::History);
let _ = avatar;Sourcepub fn tone(self, tone: AvatarTone) -> Self
pub fn tone(self, tone: AvatarTone) -> Self
Re-resolves the complete style for tone using the default theme.
This resets any custom style and size previously supplied.
§Examples
use ailloli_ui_widgets::controls::{Avatar, AvatarTone};
let avatar = Avatar::new("Ailloli").tone(AvatarTone::Accent);
let _ = avatar;Sourcepub fn avatar_style(self, style: AvatarStyle) -> Self
pub fn avatar_style(self, style: AvatarStyle) -> Self
Replaces all resolved style values without changing the stored tone.
A later Self::tone call replaces this custom style.
§Examples
use ailloli_ui_core::Theme;
use ailloli_ui_widgets::controls::{Avatar, AvatarStyle, AvatarTone};
let style = AvatarStyle::from_theme(Theme::dark(), AvatarTone::Info);
let avatar = Avatar::new("Ailloli").avatar_style(style);
let _ = avatar;Sourcepub fn size(self, value: f32) -> Self
pub fn size(self, value: f32) -> Self
Sets the preferred square size in logical pixels, clamped to 0.0.
NaN is treated as zero. Explicit layout width/height builders may
override this intrinsic size.
§Examples
use ailloli_ui_widgets::controls::Avatar;
let avatar = Avatar::new("Ailloli").size(32.0);
let _ = avatar;