pub struct Avatar { /* private fields */ }Expand description
A circular or rounded Material avatar displaying initials, an icon, an image, or custom content.
Implementations§
Source§impl Avatar
impl Avatar
Sourcepub fn initials(text: impl Into<SharedString>) -> Self
pub fn initials(text: impl Into<SharedString>) -> Self
Displays trimmed, uppercased 1–2 character initials with typography scaled to the avatar size.
Sourcepub fn icon(icon: impl IntoElement) -> Self
pub fn icon(icon: impl IntoElement) -> Self
Displays a decorative icon sized proportionally to the avatar.
Sourcepub fn image(source: impl Into<ImageSource>) -> Self
pub fn image(source: impl Into<ImageSource>) -> Self
Displays an image cropped with ObjectFit::Cover and clipped to the avatar shape.
Sourcepub fn custom(content: impl IntoElement) -> Self
pub fn custom(content: impl IntoElement) -> Self
Displays arbitrary caller-supplied visual content clipped to the avatar shape.
Sourcepub fn fallback<E: IntoElement>(
self,
fallback: impl Fn() -> E + 'static,
) -> Self
pub fn fallback<E: IntoElement>( self, fallback: impl Fn() -> E + 'static, ) -> Self
Supplies repeatable fallback visual content for Avatar::image while loading or if loading fails.
Sourcepub fn size(self, size: AvatarSize) -> Self
pub fn size(self, size: AvatarSize) -> Self
Sets the avatar diameter preset or custom pixel size. Defaults to AvatarSize::Medium (40 px).
Sourcepub fn shape(self, shape: AvatarShape) -> Self
pub fn shape(self, shape: AvatarShape) -> Self
Sets the avatar shape. Defaults to AvatarShape::Circle.
Sourcepub fn color_role(self, container: ColorRole, content: ColorRole) -> Self
pub fn color_role(self, container: ColorRole, content: ColorRole) -> Self
Resolves container and content pigments from the window theme’s semantic color roles.
Sourcepub fn colors(self, colors: AvatarColors) -> Self
pub fn colors(self, colors: AvatarColors) -> Self
Overrides container, content, and border pigments directly.
Sourcepub fn border(self, width: Pixels) -> Self
pub fn border(self, width: Pixels) -> Self
Draws an inner border stroke around the avatar perimeter in logical pixels.
Sourcepub fn accessible_label(
self,
id: impl Into<ElementId>,
label: impl Into<SharedString>,
) -> Self
pub fn accessible_label( self, id: impl Into<ElementId>, label: impl Into<SharedString>, ) -> Self
Exposes the avatar as a named Role::Image for assistive technology without adding a focus stop.
Trait Implementations§
Source§impl IntoElement for Avatar
impl IntoElement for Avatar
Source§type Element = ViewElement<Avatar>
type Element = ViewElement<Avatar>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Avatar
impl RenderOnce for Avatar
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Avatar
impl !Send for Avatar
impl !Sync for Avatar
impl !UnwindSafe for Avatar
impl Forget for Avatar
impl Freeze for Avatarwhere
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*mut dyn ElementObject: Freeze,
*const RcInner<Cell<bool>> is !null: Freeze,
PhantomData<RcInner<Cell<bool>>>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
*const ArcInner<RenderImage> is !null: Freeze,
PhantomData<ArcInner<RenderImage>>: Freeze,
*const ArcInner<Image> is !null: Freeze,
PhantomData<ArcInner<Image>>: Freeze,
*const ArcInner<dyn Fn(&mut Window, &mut App) -> Option<Result<Arc<RenderImage>, ImageCacheError>>> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&mut Window, &mut App) -> Option<Result<Arc<RenderImage>, ImageCacheError>>>>: Freeze,
*const RcInner<dyn Fn() -> AnyElement> is !null: Freeze,
PhantomData<RcInner<dyn Fn() -> AnyElement>>: Freeze,
NonZero<u32>: Freeze,
*const str is !null: Freeze,
PhantomData<&'static str>: Freeze,
*const ArcInner<ElementId> is !null: Freeze,
PhantomData<ArcInner<ElementId>>: Freeze,
impl Move for Avatar
impl Unpin for Avatarwhere
&'static str: Unpin,
Arc<str>: Unpin,
*mut dyn ElementObject: Unpin,
Rc<Cell<bool>>: Unpin,
Arc<Path>: Unpin,
Arc<RenderImage>: Unpin,
Arc<Image>: Unpin,
Arc<dyn Fn(&mut Window, &mut App) -> Option<Result<Arc<RenderImage>, ImageCacheError>>>: Unpin,
Rc<dyn Fn() -> AnyElement>: Unpin,
NonZero<u32>: Unpin,
*const str is !null: Unpin,
Arc<ElementId>: Unpin,
impl UnsafeUnpin for Avatarwhere
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*mut dyn ElementObject: UnsafeUnpin,
*const RcInner<Cell<bool>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<bool>>>: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
*const ArcInner<RenderImage> is !null: UnsafeUnpin,
PhantomData<ArcInner<RenderImage>>: UnsafeUnpin,
*const ArcInner<Image> is !null: UnsafeUnpin,
PhantomData<ArcInner<Image>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&mut Window, &mut App) -> Option<Result<Arc<RenderImage>, ImageCacheError>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&mut Window, &mut App) -> Option<Result<Arc<RenderImage>, ImageCacheError>>>>: UnsafeUnpin,
*const RcInner<dyn Fn() -> AnyElement> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn() -> AnyElement>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
*const ArcInner<ElementId> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementId>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(
self,
text: impl Into<SharedString>,
) -> ObservedText<Self::Element>
fn test_alt_text( self, text: impl Into<SharedString>, ) -> ObservedText<Self::Element>
Self::test_text for an image’s alternative text, which
stands in for what the element draws.